Combobox passing to another cbo...

Skyfighter

Member
Joined
Oct 3, 2006
Messages
7
Programming Experience
Beginner
Hi all,

I was checking out in my VB how to select an item in cbo1 and that in cbo2 items will be showed related with cbo1.

So as example: I select in cbo1 "Names with an S" and in cbo2 names would be showed beginning with an S.

Anyone has an idea?

grts and thx
 
One possibility:

VB.NET:
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=2][COLOR=#000000] Form1[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myListOfPossibilities [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] List([/SIZE][SIZE=2][COLOR=#0000ff]Of[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]
Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Form1_Load([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].Load[/SIZE]
[SIZE=2][COLOR=#0000ff] Me[/COLOR][/SIZE][SIZE=2].ComboBox1.Items.Add([/SIZE][SIZE=2][COLOR=#800000]"A"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff] Me[/COLOR][/SIZE][SIZE=2].ComboBox1.Items.Add([/SIZE][SIZE=2][COLOR=#800000]"B"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2] [/SIZE]
[SIZE=2] myListOfPossibilities.Add([/SIZE][SIZE=2][COLOR=#800000]"ADSF1"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2] myListOfPossibilities.Add([/SIZE][SIZE=2][COLOR=#800000]"ADSF2"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2] myListOfPossibilities.Add([/SIZE][SIZE=2][COLOR=#800000]"ADSF3"[/COLOR][/SIZE][SIZE=2]) [/SIZE]
[SIZE=2] myListOfPossibilities.Add([/SIZE][SIZE=2][COLOR=#800000]"BDSF1"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2] myListOfPossibilities.Add([/SIZE][SIZE=2][COLOR=#800000]"BDSF2"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2] myListOfPossibilities.Add([/SIZE][SIZE=2][COLOR=#800000]"BDSF3"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][/COLOR][/SIZE] 
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] ComboBox1_SelectedIndexChanged([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] ComboBox1.SelectedIndexChanged[/SIZE]
[SIZE=2][COLOR=#0000ff] Me[/COLOR][/SIZE][SIZE=2].ComboBox2.Items.Clear()[/SIZE]
[SIZE=2][COLOR=#0000ff] For[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] checkString [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2] myListOfPossibilities[/SIZE]
[SIZE=2][COLOR=#0000ff]  If[/COLOR][/SIZE][SIZE=2] checkString.StartsWith([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ComboBox1.SelectedItem) [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]  Me[/COLOR][/SIZE][SIZE=2].ComboBox2.Items.Add(checkString)[/SIZE]
[SIZE=2][COLOR=#0000ff]  End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] Next[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE]
 
thx for help,but in my declaration with :
Dim myListOfPossibilities AsNew List(OfString)
this error show up:
Error 1 Too few type arguments to 'System.Collections.Generic.List(Of T)'. C:\Documents and Settings\user\my documents\Visual Studio 2005\Projects\EBBR Clearance\EBBR Clearance\Clearance.vb 3 38 EBBR Clearance
 
Repasted better, I think.
VB.NET:
[/COLOR]
[COLOR=#0000ff]Public [SIZE=2]Class[/SIZE][/COLOR][SIZE=2][COLOR=#000000] Form1[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myListOfPossibilities [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] List([/SIZE][SIZE=2][COLOR=#0000ff]Of [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]
Private [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Form1_Load([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].Load[/SIZE]
[SIZE=2][COLOR=#0000ff] Me[/COLOR][/SIZE][SIZE=2].ComboBox1.Items.Add([/SIZE][SIZE=2][COLOR=#800000]"A"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff] Me[/COLOR][/SIZE][SIZE=2].ComboBox1.Items.Add([/SIZE][SIZE=2][COLOR=#800000]"B"[/COLOR][/SIZE][SIZE=2])[/SIZE]

[SIZE=2] myListOfPossibilities.Add([/SIZE][SIZE=2][COLOR=#800000]"ADSF1"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2] myListOfPossibilities.Add([/SIZE][SIZE=2][COLOR=#800000]"ADSF2"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2] myListOfPossibilities.Add([/SIZE][SIZE=2][COLOR=#800000]"ADSF3"[/COLOR][/SIZE][SIZE=2]) [/SIZE]
[SIZE=2] myListOfPossibilities.Add([/SIZE][SIZE=2][COLOR=#800000]"BDSF1"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2] myListOfPossibilities.Add([/SIZE][SIZE=2][COLOR=#800000]"BDSF2"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2] myListOfPossibilities.Add([/SIZE][SIZE=2][COLOR=#800000]"BDSF3"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Private [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] ComboBox1_SelectedIndexChanged([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] ComboBox1.SelectedIndexChanged[/SIZE]
[SIZE=2][COLOR=#0000ff] Me[/COLOR][/SIZE][SIZE=2].ComboBox2.Items.Clear()[/SIZE]
[SIZE=2][COLOR=#0000ff] For [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] checkString [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2] myListOfPossibilities[/SIZE]
[SIZE=2][COLOR=#0000ff]  If[/COLOR][/SIZE][SIZE=2] checkString.StartsWith([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ComboBox1.SelectedItem) [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]  Me[/COLOR][/SIZE][SIZE=2].ComboBox2.Items.Add(checkString)[/SIZE]
[SIZE=2][COLOR=#0000ff]  End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] Next[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE]
[COLOR=#0000ff]
 
Back
Top