Obtain textbox control in combobox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I obtain the textbox (editing field) control of the combobox? I tried
combobox.Controls to obtain the collection of controls that the combobox
contains but it turned out to be empty. Thanks.
 
Hi,

What would you do with the obtained textbox? There just might be a better
approach to solve the original problem...
 
Quan,

Can you explain more, because the textbox of the combobox is just by
instance combobox1.text

Cor
 
Hi,

The combobox is a native control, it does not have any controls inside of
it.

What do u want to do anyway?

What you may do is intercept what is written in that textbox with an event.

cheers,
 
The documentation says the combobox is composed of a textbox and a listbox,
so I thought I could extract the textbox control out of the combobox for use.
Actually, I'm trying to integrate a class library which enables input of
Vietnamese characters in TextBoxBase-derived controls
(http://vietpad.sourceforge.net/library.html). Since the handler accepts only
TextBoxBase control as parameters, I would like to get the textbox control of
the combobox. Is this possible or there is another approach to this? Thanks.
 
Hi,

What you may do is extend the Combobox class

What the documentation refer is that the combobox works "like" a
combination of those two controls.

also you could create your own control, take a look at www.opennetcf.org
they have an ownerdrawcontrol that will give you ideas

Cheers,
 
Actually, you're both correct. A combobox is indeed a core Window control,
but it is internally made up of three separate windows: the combo box window
itself, the edit control, and the drop-down list control. The edit control
and list control may or may not exist, depending on the combo-box style (see
ms-help://MS.MSDNQTR.2004APR.1033/shellcc/platform/commctls/comboboxes/aboutcomboboxes.htm
for more detail on this). The thing is that these controls are Windows
controls, and not .NET controls. Therefore we deal in HWNDs and not Control
subtypes.

In order to get the HWND of the edit control of a combo box, you must use
the SendMessage Windows API call to send the CB_GETCOMBOBOXINFO message to
the combo box control. The COMBOBOXINFO structure returned by this call will
contain the edit controls HWND in its hwndItem field.

However, before you get excited, there's one huge problem which is that an
HWND to an edit box cannot be converted into a TextBoxBase, at least not as
far as I know.
 
Back
Top