winform 的 radiobutton 怎么绑定 bool值
比如我有男和女的两个radiobutton ,但是每个的数据绑定都是单个
checked的绑定,怎么设置才能是这两个控件一个的true 绑定男,一个绑定女呢

解决方案 »

  1.   

    DataTable dt = new DataTable();
    dt.Columns.Add("sex", typeof(bool));
    dt.Rows.Add(new object[]{true});
    checkBox1.DataBindings.Add("Checked", dt, "sex");
      

  2.   

    有个问题,有两个winform 的 radiobutton 的一个男,一个表示女
    点的话,两个都是true ,但是一个表示男,一个表示女
    checkBox1.DataBindings.Add("Checked", dt, "sex");
    绑定是可以,但是,没有办法改变男女
      

  3.   

    用过第三方控件DevExpress吗?这个问题很容易解决:
    DataTable dt = new DataTable();
    dt.Columns.Add("sex", typeof(bool));
    dt.Rows.Add(new object[]{false});radioGroup1.Properties.Items.AddRange(new DevExpress.XtraEditors.Controls.RadioGroupItem[] {new DevExpress.XtraEditors.Controls.RadioGroupItem(true, "男"), new DevExpress.XtraEditors.Controls.RadioGroupItem(false, "女")});
    radioGroup1.Properties.NullText = "true";this.radioGroup1.DataBindings.Add("EditValue", dt, "sex");
      

  4.   

    不用第三方控件也可以变通地解决
    DataTable table1 = new DataTable();
    // 给table1赋值
    table2 = table1.Copy();
    // 把table2中的男女字段布尔值取反
    table1绑定CheckBox1,table2绑定CheckBox2
      

  5.   

    昏死,微软的控件太滥了,连一可简单的bool绑定都没有,应该学学
    delphi,
    谢谢个位,我用DevExpress就可以了
    ==========
    DevExpress 好是好,但是太好我内存,一可datagird,单当编辑界面的是否,
    我的内存就涨到700M,硬盘狂闪