n3bi0s
n3bi0s

Reputation: 145

Windows Form Combobox Selecteditem

when editing a specific record in a listview row, how do I get that value to the corresponding combobox selected item/value?

The combobox is in dropdownlist style mode, so the selected text wont work.

i tried this:

cbBrand.SelectedItem = lvMain.SelectedItems[0].SubItems[1].ToString();

but i get null in the corresponding combobox selecteditem... :(

Upvotes: 0

Views: 2658

Answers (2)

n3bi0s
n3bi0s

Reputation: 145

I got it working like this:

int xcb;
xcb = this.cbBrand.FindString(lvMain.SelectedItems[0].SubItems[1].Text);
this.cbBrand.SelectedIndex = xcb;

Upvotes: 1

Morten
Morten

Reputation: 3844

You can use the SelectedValue property.

Upvotes: 0

Related Questions