"John" <ju**@junk.com> wrote in message
news:e4**********@perki.connect.com.au...
"TheSteph" <Th******@NoSpam.com> wrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
Are you sure that the value in the grid is equal to one of the value
populated in the Combobox ?
Hmmm. There are no values in the grid, this is on editing a new row. I
think I need to set up an initial value for the column.
"John" <ju**@junk.com> wrote in message
news:e4**********@perki.connect.com.au...
Hi,
I've been trying to populate a DataGridViewComboBoxColumn with objects.
The object is defined as :
private struct manufactItem
{
public string name;
public Guid? man_id;
public override string ToString()
{
return name;
}
}
And they are inserted like so :
for (int i = 0; i < ds.Tables["RESULT"].Rows.Count; i++)
{
mi = new manufactItem();
mi.man_id = (Guid)ds.Tables["RESULT"].Rows[i]["MAN_ID"];
mi.name = ds.Tables["RESULT"].Rows[i]["NAME"].ToString();
int pos = (dgvManAlternatives.Columns["ALT_MANUFACTURER"] as
DataGridViewComboBoxColumn).Items.Add(mi);
}
This is all well and good, and when the cell on the grid is clicked the
pulldown list is populated. The problem I am having is when I move out
of
the cell, I get
"DataGridViewComboBoxCell value is not valid"
Can I only put string values into the DataGridViewComboBoxColumn?
John.
Initialization is not the problem. I think this has something to do with the
MemberValue. It looks like a DataGridViewComboBox just wont work with
anything other than strings unless it is being used in a bound mode. Somehow
I have to provide it functionality to do a lookup from the string value
selected to the actual object that string represents.
Anyone know how?