给里段代码参考下吧,呵呵DataGridColumnStyle boolCol = new DataGridBoolColumn(); boolCol.MappingName = "Current"; boolCol.HeaderText = "IsCurrent Customer"; boolCol.Width = 150; ts1.GridColumnStyles.Add(boolCol);DataTable tCust = new DataTable("Customers");
// Create one column, and add it to the first table.
DataColumn cCurrent = new DataColumn("Current", typeof(bool)); tCust.Columns.Add(cCurrent); // Add the tables to the DataSet. myDataSet.Tables.Add(tCust);myDataGrid.SetDataBinding(myDataSet, "Customers");
谢谢,我知道怎回事了。代码没问题,主要是DataColumn cCurrent = new DataColumn("Current", typeof(bool)); 我字段是从数据库取的,类型不是BOOL我晕~~还有这种错误 谢谢各位了。
this.BoolColumn.HeaderText = "是否显示";
this.BoolColumn.MappingName = "isShow";
this.BoolColumn.NullValue = "true";
this.BoolColumn.TrueValue = "true";
this.BoolColumn.Width = 75;
boolCol.MappingName = "Current";
boolCol.HeaderText = "IsCurrent Customer";
boolCol.Width = 150;
ts1.GridColumnStyles.Add(boolCol);DataTable tCust = new DataTable("Customers");
// Create one column, and add it to the first table.
DataColumn cCurrent = new DataColumn("Current", typeof(bool)); tCust.Columns.Add(cCurrent); // Add the tables to the DataSet.
myDataSet.Tables.Add(tCust);myDataGrid.SetDataBinding(myDataSet, "Customers");
我字段是从数据库取的,类型不是BOOL我晕~~还有这种错误
谢谢各位了。