Click here to Skip to main content
15,920,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want use List<bindentity> bind to DataGridViewComboBoxColumn as a custom datasource.but always occur a dataerror when ui show.i get error message ,it's about cell value illegal .
what should i do ?
code list below:

enum ComStationType { PCPSYS,ESPSYS...}

class BindEntity
{
public string Name{get}
public object Value{get}
}

DataGridViewComboBoxColumn dgvc = new DataGridViewComboBoxColumn();
dgvc.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
dgvc.DataPropertyName = "column1";
dgvc.DataSource = GetComStationTypeInfo();//GetComStationTypeInfo() return a List<bindentity> for bind!
dgvc.DisplayMember = "Name";
dgvc.ValueMember = "Value";

this.dataGridView1.Columns.Add(dgvc);

DataTable dt = new DataTable();
dt.Columns.Add("column1", typeof(ComStationType));
DataRow dr = dt.NewRow();
dr[0] = ComStationType.ESPSYS;
dt.Rows.Add(dr);

this.dataGridView1.DataSource = dt;
Posted
Updated 12-Dec-12 22:40pm
v2

1 solution

I also had such errors when binding a combo in a datagrid...

my workaround was to implement a IValueConverter to the binding, and handled there the NULL errors.
regards
Patrick
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900