ListBox DataSource DisplayMember Property Problems

I

Irwin M. Fletcher

ListBox DataSource DisplayMember Property
Problems in C#

I have a (single select) listbox with data and
when I click on the list I can't get the right
text selected.

My listbox is setup using the DataSource property.
I set my ValueMember and DisplayMember
listBox1.ValueMember = "TypeID";
listBox1.DisplayMember = "Name";

I am able to get the "TypeID" (ValueMember) when I click on
the items.
I do that like this...
int intTest;
intTest = System.Int32.Parse(listBox1.SelectedValue.ToString());

But I can't get the text (DisplayMember).
I have used these two ways, but...
string strDispMem;
strDispMem = listBox1.Items[index].ToString();
// the above returns... "System.Data.DataRowView"

or
strDispMem = listBox1.Text;
// The above repeats first selection the user clicks on.


Any ideas???
Thanks... Irwin
 

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