Groups | Blog | Home
all groups > c# > january 2005 >

c# : Obtain textbox control in combobox


Quan Nguyen
1/5/2005 11:43:03 PM
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
Quan Nguyen
1/6/2005 9:33:04 AM
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
Dmitriy Lapshin [C# / .NET MVP]
1/6/2005 10:05:18 AM
Hi,

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

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

[quoted text, click to view]
Cor Ligthert
1/6/2005 10:14:10 AM
Quan,

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

Cor

"Quan Nguyen" <QuanNguyen@discussions.microsoft.com>

[quoted text, click to view]

Ignacio Machin ( .NET/ C# MVP )
1/6/2005 10:42:13 AM
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,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


[quoted text, click to view]

Ignacio Machin ( .NET/ C# MVP )
1/6/2005 2:33:39 PM
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,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

[quoted text, click to view]

Sean Hederman
1/6/2005 10:08:20 PM
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.

[quoted text, click to view]

AddThis Social Bookmark Button