SBendBuckeye
Programmer
Hello all,
I am trying to get a reference to the hiddent textbox behind a combobox using the following code. The handle changes but FromHandle(handle) line always returns Nothing.
Does anyone have any ideas and/or suggestions? Thanks in advance!
Have a great day!
j2associatesNO_SPAM@gmail.com
I am trying to get a reference to the hiddent textbox behind a combobox using the following code. The handle changes but FromHandle(handle) line always returns Nothing.
Code:
<DllImport("user32", CharSet:=CharSet.Auto)> _
Private Shared Function FindWindowEx(ByVal hwndParent As IntPtr, _
ByVal hwndChildAfter As IntPtr, _
<MarshalAs(UnmanagedType.LPTStr)> _
ByVal lpszClass As String, _
<MarshalAs(UnmanagedType.LPTStr)> _
ByVal lpszWindow As String) As IntPtr
' Function body should be empty.
End Function 'FindWindowEx
' Control is a ComboBox.
Public Shared Function GetHiddenTextBox(ByVal control As Windows.Forms.Control) As Control
Dim handle As IntPtr = control.Handle
If GetType(System.Windows.Forms.ComboBox).IsAssignableFrom(control.GetType) Then
handle = FindWindowEx(handle, IntPtr.Zero, "EDIT", "" & Microsoft.VisualBasic.Chr(0) & "")
End If
Return System.Windows.Forms.Control.FromHandle(handle)
End Function 'GetHiddenTextBox
Have a great day!
j2associatesNO_SPAM@gmail.com