I have a combo box which is in set to be a drop down list. How do I change the label text based on which ID is selected in the combo box. How do I make the label text change to the corresponding row as the ID?

Thanks

Recommended Answers

I'm not sure what you're asking for. You can get/set the user value associated with a list/combo item.

You can add and remove items.

Jump to Post

You click a listbox or combobox, it returns the index of that item.
You use that index to get the name, or the user data value.

Not the other way around!

Jump to Post

All 5 Replies

I'm not sure what you're asking for. You can get/set the user value associated with a list/combo item.

You can add and remove items.

I'm not sure what you're asking for. You can get/set the user value associated with a list/combo item.

You can add and remove items.

If I have a list of Names in the dataset and each have an ID and I have a combo box that displays the list of IDs. If I click an ID how to I get the label to show the name corresponding to that ID that was selected from the combobox.

Thanks

You click a listbox or combobox, it returns the index of that item.
You use that index to get the name, or the user data value.

Not the other way around!

DataRow[] rows = yourTable.Select(string.Format("ID='{0}'",cbIDs.Text));

yourLabel.Text = (string)rows[0]["Name"];

Thanks guys! That should help me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.