displaying array values on combobox selectedindexchanged event?
Posted on 2006-11-29
I have a combobox populated by an array datasource, and a label.
Me.ComboBox1.DataSource = myPrintersArray
Me.ComboBox1.DisplayMember = "DeviceID"
Me.ComboBox1.ValueMember = "DeviceID"
myPrintersArray holds the "DeviceID" and "Location" of several printers
On the selectedindexchanged event I would like to display the "Location" of the selected Printer.
Public Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If I change .ValueMember to ="Location", this is easy enough. But can it be done without passing the Location into the Combobox itself? I ask because I may have to expand the array to include the "Name" of the printers. So .DisplayMember would be "Name", .ValueMember would be "DeviceID", and I could not specify "Location" anywhere in the Combobox.