Is there a specific reason you need the class at all? ie do you NEED to use .SelectedItem or why not just use .SelecteValue?
cboTax1.DisplayMember = "DisplayValue";
cboTax1.ValueMember = "TxCode";
cboTax1.DataSource = new BindingSource(cbocmd.Execu
that binds everything, then you can set and retrieve by TxCode by getting / setting cboTax1.SelectedValue
Main Topics
Browse All Topics





by: federicomarinucciPosted on 2009-10-30 at 09:11:23ID: 25704374
Create a static method in an external class to aid you: ;
-----
internal string[][] PopulateCB(Combobox cb, string[][] values){
cb.Items.Clear();
string[][] container = new string[values.Length][];
for (int x = 0; x< values.Length; x++){
string itemValue = values[x][0];
cb.Items.Add(itemValue);
container[x] = new String[values[x].Length-1]
for (int y = 0; y < container.Length; y++){
container[x][y] = values[x][y+1];
}
}
return container;
}
-----
This way, you just have to get the items in a string[ROW][COLUMN] way, having in COLUMN zero the value you wish to display in the Combobox; then, to retrieve which ROW has been selected, you may simply use the ComboBox.SelectedIndex as index for your container's ROW, leading you to the other values of that ROW (such as ID or anything else).