Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ComboBox SelectedItem / SelectedValue

Status
Not open for further replies.

BoulderBum

Programmer
Jul 11, 2002
2,179
US
I'm going a little nuts trying to figure out combo box binding. I figured out that I have to move the DataSource code above the DisplayMember and ValueMember declarations, but when I try to access SelectedItem or SelectedValue, all I get is System.Data.DataRowView.

What am I doing wrong?

Code:
lbParameters.DataSource = ds.Tables[0]; //ds is a DataSet
lbParameters.DisplayMember = "field_text";
lbParameters.ValueMember = "type_description";

...

private void lbParameters_SelectedIndexChanged(object sender, System.EventArgs e)
{
      if( lbParameters.SelectedIndex != -1 )
      {
      Debug.WriteLine( lbParameters.SelectedItem.ToString() );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top