Click here to Skip to main content
15,877,618 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
When i select an item in combobox1 suppose pen
then its subitems should come in combox2 say parker, lexi etc. ..

how do i do this in visual studio 2005 ... i use vb ..



MSIL
Thnx ..very much for the help ...
but my dobut still exits ..this talks about creating a new web site ... and all ...
what i want is ..i just want to implement this in a form of my program ...
that is Ther is a combobox named Items and ..its sub combobox products ..
so ..when i selct an item from Items its sub products should come in sub combo box .. how will i do it from ..database ...
plz help ..




SQL
Hook the ComboBox.SelectedValueChanged event, and update the second ComboBox based on that value.
Can you please tell me how i will ..do this ..with some eg:.. im a new bie ...



i dont ..take it rude its a great help that you are doing to me .. can you please tell me which text i can refer ..and page number if u know them ... i tried a lot ..but did not find ...much useful ...
Posted
Updated 9-Mar-10 8:17am
v4

Hmm...I'm curious how a VB.Net question was solved with an ASP answer.

If this is ASP, it should have been marked that way. Otherwise, an ASP control will not work in a WinForms app.

The idea is the same as the cascading drop down, but you'll have to implement it yourself if it's a WinForms app.

Hook the ComboBox.SelectedIndexChanged event, and update the second ComboBox based on that value.


[To your other question about this]

Sorry, but not to be rude, but if you don't understand "Hook the ComboBox.SelectedIndexChanged event, and update the second ComboBox based on that value." then, you need to buy some books.

Within your code, the hook and code looks something like:
VB
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles ComboBox1.SelectedIndexChanged
  If ComboBox1.SelectedText = "Pen" Then
    ComboBox2.Items.Clear
    ComboBox2.Items.Add("Mont Blanc")
    ComboBox2.Items.Add("Parker")
    ...

    ComboBox2.Text = "<Select a Pen Brand>"
  End If
End Sub


[Modified]
So, seriously, who is it that has a problem with me personally and keeps voting my answers as a 1?

Was my information factually incorrect? No!

Was my information unuseful because it was for a different language (like answering a VB.Net question with an ASP.Net answer)? No!

If you have a problem with me, post something in the forum...don't confuse people by saying the answer is wrong, which it is not.
 
Share this answer
 
v3
You can try:

Visual Basic .NET for Dummies[^]

Try the chapter on "Showing Choices with List and Combo Boxes " I don't have the book, so I can't tell you what page and my VB books are at home.
 
Share this answer
 
Here you go:
CascadingDropDown Demonstration[^]

You can also make like this, step by step:
Creating a CascadingDropDown Using AJAX[^]
 
Share this answer
 
v2

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