Salve,
Stiamo completando una combo estesa che ,invece di mostrare la solita lista OneClicked per effettuare la scelta, mostri una ListBox o CheckedListBox con possibilita' di multi selezione.
Il controllo e' gia realizzato ma manca la possibilita' di bindate tale controllo ad una Source dati.
- Public Overloads Property DataSource() As Object
abbiamo provato ad implementare l overloads della property ma il problema rimane.
Chibeca Software - Team AA
Public Class extCombo : Inherits ComboBox
Private Const LBUTTONDOWN = &H201
Private Const WM_LBUTTONDBLCLK = &H203
'variabile dropdown
Private isDropDownVisible As Boolean = False
Private _DataSource As Object
Private _DataMember As String
Private _host As ToolStripControlHost
Private _dropDown As ToolStripDropDown
Private WithEvents _lb As ListBox
#Region "_______________________________________________________"
Public Sub extCombo(ByVal s As Object, ByVal m As String)
_lb = New ListBox
_lb.BorderStyle = BorderStyle.None
_lb.DataSource = s
_lb.DisplayMember = m
_host = New ToolStripControlHost(_lb)
_dropDown = New ToolStripDropDown()
_dropDown.Width = Me.Width
_dropDown.Height = 100
_dropDown.Items.Add(_host)
End Sub
#End Region
Public ReadOnly Property ListBox() As ListBox
Get
Return _host.Control
End Get
End Property
Public Overloads Property DataSource() As Object
Get
Return _DataSource
End Get
Set(ByVal value As Object)
_DataSource = value
_lb.DataSource = value
End Set
End Property
Public Property DataMember() As String
Get
Return _DataMember
End Get
Set(ByVal value As String)
_DataMember = value
_lb.DisplayMember = value
End Set
End Property
Private Sub ShowDropDown()
If _dropDown IsNot Nothing Then
_dropDown.Show(Me, Me.Width - Me.Left, Me.Height)
_dropDown.Visible = True
End If
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_LBUTTONDBLCLK Or m.Msg = LBUTTONDOWN Then
If isDropDownVisible = False Then
ShowDropDown()
isDropDownVisible = True
Exit Sub
Else
isDropDownVisible = False
Exit Sub
End If
End If
MyBase.WndProc(m)
End Sub
End Class