Hello Experts!
I have a DataGridView grd
when add one column :
DataGridViewComboBoxColumn
cl=new DataGridViewComboBoxColumn
();
cl.DisplayMember="szString
";//proper
ty of my object
cl.DefaultCellStyle.NullVa
lue="Selec
t data";
foreach(MyObject obj in MyArrayOfObject)
{
cl.items.Add(cl);
}
grd.Columns.Add(cl);
Then I add new cell of row:
DataGridViewRow row=new DataGridViewRow();
DataGridViewComboBoxCell cell=new DataGridViewComboBoxCell()
;
cell=(DataGridViewComboBox
Cell)grd.C
olumns[0].
CellTempla
te.Clone()
;
cell.Value=null;//cell.Val
ue = new MyObject("String");
row.Cells.Add(cell);
grd.Rows.Add(row);
It's work fine!
But when I set value of cell diferent of null (what in comment: cell.Value = new MyObject("String");), It's raise exception: value is invalid even the new MyObject("String") is same as one in MyArrayOfObject
Can anyone help!
Thanks in advanced!
HuyBD;
Start Free Trial