[RESOLVED] [2005] Sendmessage and Combobox
I'm attempting to find an item in a combo box using the below code however each time it returns 0 (which is incorrect)? Any suugestions?
Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Const CB_FINDSTRING As Integer = &H14C
Dim index as Long
index = SendMessage(cboPriceStyles.HostedControl.Handle, CB_FINDSTRING, -1, "Bar")
Re: [2005] Sendmessage and Combobox
Why do you use SendMessage API function to get the index of the ComboBox item? You can simply use IndexOf method of ComboBox.Items to get the index of the item with simple data type.
vb Code:
Dim index As Integer
index = Me.ComboBox1.Items.IndexOf("Bar")
Re: [2005] Sendmessage and Combobox
You can also use ComboBox.FindString function which finds the first item in the combo box that starts with the specified string.
Re: [2005] Sendmessage and Combobox
Thanks. I had used SendMessage in VB6. I guess there are a few things different in VB.net :)