Auto select in listbox when user types in textbox



Help!

I used to user the following code in VB6 to scroll the listbox in response
to a user typing in text:

In a module:

Public 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

Public Const LB_SELECTSTRING = &H18C

In a form:

Private Sub txtLstAll_Change()
If txtLstAll.Text <> "" Then
SendMessage lstAll.hwnd, LB_SELECTSTRING, -1, txtLstAll.Text
End If
End Sub

I tried this in the NEW IMPROVED Visual Studio 2008, using vb and I am
getting the following error message:

'hwnd' is not a member of 'System.Windows.Forms.ListBox'.

Does anyone know if there Is there a way of doing this in 2008? ANY help or
if you could point me in the right direction to find something would really
be appreciated!
--
Sheldon
.



Relevant Pages

  • Re: Sending strings from one app to another
    ... Public Declare Function SetDlgItemText Lib "user32" _ ... Alias "SetDlgItemTextA" _ ... Where hwnd is the handle of the target text box: ... SendMessage hwnd, WM_SETTEXT, 0, ByVal "Hello World - whatever" ...
    (microsoft.public.vb.general.discussion)
  • Re: WM_SETTEXT sets garbage characters
    ... Public Declare Function SendMessage Lib "user32" Alias ... Try passing strFolder ByVal. ... ' Set Edit text box with path: ...
    (microsoft.public.vb.general.discussion)
  • Re: EM_CHARFROMPOS always return -1
    ... Public Declare Function SendMessage Lib "user32" Alias ... "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam ... lParam As Any) As Long ...
    (microsoft.public.vb.winapi)
  • Re: window messages
    ... Public Const WM_COMMAND = &H111 ... Public Declare Function GetDlgCtrlID Lib "user32" _ ... Dim wParam As Long ... SendMessage hChild,CB_SELECTSTRING, -1&, ByVal TempString ...
    (microsoft.public.vb.winapi)