I am in the process of designing my own control that inherits from combobox.
I have created my own collection class to replace ComboBox.Items and when an
item is added to this collection, I use the user32.dll SendMessage to add an
item to the ComboBox. Up to that point, everything seems to work fine.
However, when I pull down the listbox (the items paint fine too) and select
an item, my combobox's edit control is filled with garbage. I think my
implementation of the SendMessage may be the culprit, so here it is:
Public Class ExtendedCombobox
Inherits Combobox
Private Declare Ansi Function SendMessage Lib "user32" Alias
"SendMessageA" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As
Object, ByVal lParam As String) As Integer
Private WithEvents mocItems As WRS.ExtendedCombobox.ObjectCollection
Public Shadows ReadOnly Property Items() As
ExtendedCombobox.ObjectCollection
Get
Return mocItems
End Get
End Property
Private Sub mocItems_ItemAdded(ByVal sender As Object, ByVal e As
CustomUtilities.PropertyChangeEventArgs) Handles mocItems.ItemAdded
Dim strAdd As String
Const cbAddString=&H143
If Len(ValueMember) > 0 Then
strAdd = CType(e.PropertyObject, ListRow)(ValueMember).Value
Else
strAdd = CType(e.PropertyObject, ListRow)(1).Value
End If
SendMessage(Me.Handle, cbAddString, 0, strAdd)
End Sub
End Class
Thanks
--
Pat