Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Intermediate
Sep 9, 2002

Set the Text of the Edit Control Portion of a ComboBox


The following is a way to programatically set the text in the combo box without adding to the list box portion.

When using a combo box, if the style is CBS_DROPDOWN, users can enter any text in the edit box portion of it. There is no direct way of adding text to a combo box's edit control without adding it to the listbox as well. Programmers usually insert the required text to the list box of the combo box and then select the text to achieve the desired result.

Because this method may be unacceptable in certain cases, the following method is useful.

Assume hCombo is the window handle of the combo box.
 
POINT point;
point.x = 1;
point.y = 1;
HWND hEdit = ChildWindowFromPoint(hCombo, point);
SetWindowText(hEdit,"Hello World");
Rajesh Chathapuram
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date