Public Class RoComoboBox
Inherits System.Windows.Forms.ComboBox
Private _readOnly As Boolean
#Region " Windows フォーム デザイナで生成されたコード "
Public Sub New()
MyBase.New()
' この呼び出しは Windows フォーム デザイナで必要です。
InitializeComponent()
' InitializeComponent() 呼び出しの後に初期化を追加します。
End Sub
'UserControl はコンポーネント一覧を消去するために dispose をオーバーライドします。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
' Windows フォーム デザイナで必要です。
Private components As System.ComponentModel.IContainer
' メモ : 以下のプロシージャは、Windows フォーム デザイナで必要です。
'Windows フォーム デザイナを使って変更してください。
' コード エディタを使って変更しないでください。
Friend WithEvents ctmEmpty As System.Windows.Forms.ContextMenu
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.ctmEmpty = New System.Windows.Forms.ContextMenu
End Sub
#End Region
Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
If Me.ReadOnly = True Then
e.Handled = True
End If
End Sub
Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs)
If Me.ReadOnly = True Then
e.Handled = True
End If
End Sub
Property [ReadOnly]() As Boolean
Get
Return _readOnly
End Get
Set(ByVal Value As Boolean)
_readOnly = Value
If (_readOnly = True) Then
Me.ContextMenu = ctmEmpty
Me.SetStyle(ControlStyles.Selectable, False)
Me.SetStyle(ControlStyles.UserMouse, True)
Me.UpdateStyles()
Me.RecreateHandle()
Else
Me.ContextMenu = Nothing
Me.SetStyle(ControlStyles.Selectable, True)
Me.SetStyle(ControlStyles.UserMouse, False)
Me.UpdateStyles()
Me.RecreateHandle()
End If
End Set
End Property
End Class
|