在设置DataGrid样式时,把该列的AllowNull设为false

解决方案 »

  1.   

    DataSet1.Tables("Customers").Columns("Sex").AllowDBNull = False
      

  2.   

    DataColumn tc= new DataColumn("Select", System.Type.GetType("System.Boolean"));
    tc.DefaultValue = false;
    tc.AllowDBNull = false;
    oDataTable.Columns.Add(tc);
    .......
    ......
    .....
    ....
    ...
    DataGridTableStyle myTableStyle = new DataGridTableStyle();
    myTableStyle.MappingName = tableName; //选择列
    DataGridBoolColumn boolCol=new DataGridBoolColumn();
    boolCol.MappingName = "Select";
    boolCol.HeaderText = "选择";
    boolCol.NullValue=false;
    boolCol.Width = 30;
    myTableStyle.GridColumnStyles.Add(boolCol);我的代码如上,可是 DataGrid中的CheckBox控件只有三种状态(选取和未选取,变灰)!! 
      

  3.   

    没错:AllowDBNull = false,加列时属性列不允许为空就可以了
      

  4.   

    knoros2005(JJYY) ,,你说有,,就发表下嘛,,不就一句话,,开发不是把精神放在找东西上的,象这样的问题,,大家指醒一下就OK的嘛,,省得浪费我们宝贵时间