jaw0807
asked on
collection as combobox datasource
I'm a VB.NET novice and am having difficulty retrieving collection data.
I have a combobox using a collection as the datasource:
Dim PrinterCollection As New Collection
Me.ComboBox1.DataSource = PrinterCollection
Me.ComboBox1.SelectedIndex = 0
On SelectIndexChanged I would like to display the contents of the collection depending on what is selected in ComboBox1, but I'm not sure how to access the collection data:
Public Sub ComboBox1_SelectedIndexCha nged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexCha nged
'Me.Label1.Text = PrinterCollection(Me.Combo Box1.Selec tedIndex) -- does not work
End Sub
Also, should I declare the variable PrinterCollection in a module to set it as a global variable? The variable scope differences between VB6 and VB.NET have me a bit confused.
I have a combobox using a collection as the datasource:
Dim PrinterCollection As New Collection
Me.ComboBox1.DataSource = PrinterCollection
Me.ComboBox1.SelectedIndex
On SelectIndexChanged I would like to display the contents of the collection depending on what is selected in ComboBox1, but I'm not sure how to access the collection data:
Public Sub ComboBox1_SelectedIndexCha
'Me.Label1.Text = PrinterCollection(Me.Combo
End Sub
Also, should I declare the variable PrinterCollection in a module to set it as a global variable? The variable scope differences between VB6 and VB.NET have me a bit confused.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER