tsy
04-06-2006, 01:05 AM
The Combo Box does not have a read only property... thus i have created one for it and have cancelled the keypress event but i dont know how to cancel the mouse click event. My code is below, can someone please help me out.
Public Class ReadOnlyComboBox
Inherits System.Windows.Forms.ComboBox
Private _readOnly As Boolean
Public Sub New()
MyBase.New()
_readOnly = False
End Sub
Public Property ReadOnlyCombo() As Boolean
Get
Return _readOnly
End Get
Set(ByVal value As Boolean)
_readOnly = value
End Set
End Property
Private Sub ReadOnlyKeyHandler(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
If _readOnly Then
e.Handled = True
End If
End Sub
Private Sub ReadOnlyMouseHandler(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
If _readOnly Then
'how do i cancel this event
End If
End Sub
End Class
Public Class ReadOnlyComboBox
Inherits System.Windows.Forms.ComboBox
Private _readOnly As Boolean
Public Sub New()
MyBase.New()
_readOnly = False
End Sub
Public Property ReadOnlyCombo() As Boolean
Get
Return _readOnly
End Get
Set(ByVal value As Boolean)
_readOnly = value
End Set
End Property
Private Sub ReadOnlyKeyHandler(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
If _readOnly Then
e.Handled = True
End If
End Sub
Private Sub ReadOnlyMouseHandler(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
If _readOnly Then
'how do i cancel this event
End If
End Sub
End Class