Getting SelectedText/Item from ComboBox

G

Guest

I have a WinForm ComboBox that is populated by binding to a dataset that
contains a list of employees (two columns: 1. employee id, 2. employee name).
The id is bound to the ValueMember, the name to the DisplayMember. The
dataset is then disposed.

When an item is selected from the combobox, the value is easy to get. Yet
when I try to capture the selected text I get a "DataRowView" back. I've
tried to work my way through the DataRowView but I keep hitting a wall. Is
there a simple way to access the selected DisplayMember? It shouldn't be this
difficult.

Thank you
 
M

Mythran

ASP Yaboh said:
I have a WinForm ComboBox that is populated by binding to a dataset that
contains a list of employees (two columns: 1. employee id, 2. employee
name).
The id is bound to the ValueMember, the name to the DisplayMember. The
dataset is then disposed.

When an item is selected from the combobox, the value is easy to get. Yet
when I try to capture the selected text I get a "DataRowView" back. I've
tried to work my way through the DataRowView but I keep hitting a wall. Is
there a simple way to access the selected DisplayMember? It shouldn't be
this
difficult.

Thank you

Isn't it something like:

cboBox.Items[cboBox.SelectedIndex].Text

??

HTH,
Mythran

(P.S. Not sure, I haven't created winform app in a long time)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top