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!

How to retrieve object data from combobox?

Status
Not open for further replies.

hh2424

Programmer
Feb 18, 2003
37
US
//I have the following data bind to a comboBox

public struct DataContainer
{
private string pvrKey, prvValue;

public DataContainer(string parKey , string parValue)
{
this.pvrKey = parKey ; this.prvValue = parValue ;
}

public string getKey { get { return pvrKey; } }
public string getValue { get { return prvValue; } }
}



ArrayList CmbData = new ArrayList ();

while (dr.Read())
{
CmbData.Add (new DataContainer(Convert.ToString(dr.GetValue(dr.GetOrdinal("CustKey"))), Convert.ToString(dr.GetValue(dr.GetOrdinal("CustName")))));
}

this.cmbAccountName.DataSource = CmbData;
this.cmbAccountName.DisplayMember = "getValue";


// When the user selects an item from the combobox
// How can I retrieve the "Key" value of the object the user selected?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top