I have 2 types of datagrid combobox columns. One where the value member is an integer (ID) and another where the value member is a string(Shortname). The display member (Longname) in both are strings.
The one with the string value member works fine.
The one with the integer displays the value member (the integer) instead of the display member. The drop down list is correct and I can select one, but when i leave the column it diplays the integer ID instead.
DataGridViewComboBoxColumn dgvCBcol = new DataGridViewComboBoxColumn();
dgvCBcol.Name = col.ColName;
dgvCBcol.DataPropertyName = col.ColName;
if (col.ColName == "DLQ_FREQ")
{
// this is the one with an integer
List<clsItemsNumID> cmb = col.CmbItemsNumID as List<clsItemsNumID>;
dgvCBcol.DataSource = cmb;
dgvCBcol.ValueMember = "ID";
}
else
{ // this is the one with a string
List<cmbAlias> cmb = col.CmbItems as List<cmbAlias>;
dgvCBcol.DataSource = cmb;
dgvCBcol.ValueMember = "ShortName";
}
dgvCBcol.Width = 100;
dgvCBcol.DisplayMember = "LongName";
dgvCBcol.HeaderText = col.ColHdrText;
dgvCBcol.SortMode = DataGridViewColumnSortMode.Automatic;
//********clsItemsNumID is as follows
public class clsItemsNumID
{
private string longName;
private int id;
public int ID
{
get { return id; }
set { id = value; }
}
public string LongName
{
get { return longName; }
set { longName = value; }
}
public clsItemsNumID(int ID, string LongName)
{
this.id = ID;
this.longName = LongName;
}