Click here to Skip to main content
15,885,952 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Can someone point me in the right direction? I can't locate documentation on this subject. I want to be able to have the data in a combo box change depending on the data selected in another combo box.For example, if I select GOLF CLUBS in one combo box the next combo box will contain the MANUFACTURERS of GOLF CLUBS, if I change GOLF CLUBS to CARS the next combo box will contain the MANUFACTURERS of CARS.
Posted
Updated 30-Jun-11 17:06pm
v3
Comments
Chuck O'Toole 30-Jun-11 14:27pm    
Can you clarify this? "Select" seems to imply a "Combo Box", commonly called a pulldown list. Edit Boxes are where people type in unconstrained text. Are you expecting the user to enter the exact text "GOLF CLUBS" or are you expecting them to select "GOLF CLUBS" from a list of choices in a pulldown list? Makes a difference in the answer you'll get
DrBones69 30-Jun-11 14:32pm    
I'm sorry, yes these are combo boxes that I'm working with.
Sergey Chepurin 30-Jun-11 15:24pm    
There is absolutely no need for a second combo box. You select golf clubs from ComboBox, but output corresponding manufacturers in TextBox.

All you have to do is reload the dependent combobox every time the user selects something on the first.

Topics to research:
Load CComboBox Dynamically[^]
Capture user selection in CComboBox[^]

A couple of different approaches you can take on the dependent box:
- Leave it blank until user selects something.
- Fill in based on default choice for first.
- Don't show it until user selects something from first.
 
Share this answer
 
You can use cascading dropdowns with WebMethods or normal dropdowns (aided by JQuery & JSON) also.

Hope this helps!
 
Share this answer
 
in c# its possible
txtBox1.Text = txtBox2.SelectedText;


try if it also work with c++...
 
Share this answer
 
Comments
DrBones69 30-Jun-11 14:35pm    
Doesn't that make txtBox1 contain the same data as the selected text in txtBox2?
theanil 30-Jun-11 14:54pm    
txtBox1.Text ="your data" + txtBox2.SelectedText;
yes it will, but once your work is done you can use clear.
theanil 30-Jun-11 14:56pm    
one advice, use lable insted of text box with nice font it will give good look to your application.
OK, so I finally made the combo boxes perform the way I wanted. I used ON_CBN_CLOSEUP and ON_CBN_SELCHANGE to get the job done. But, can someone tell me why the event handlers act differently when I change between types? (DropDown or DropList)

If I choose an element of the DropDown combo box, the event handler isn't called unless I select the element again. But when I change to DropList, the event handler is called the first time I select an element. Again, does anyone know why?

Thanks,
Randy
 
Share this answer
 
Comments
Albert Holguin 6-Jul-11 21:36pm    
I believe they're considered different types of controls, so its fair to assume the event handlers are going to be triggered differently, but I haven't looked closely enough to see the exact behavior you're describing. If I had to guess, one of those has the event handling to support highlighting multiple entries and the other does not (just a guess).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900