可以把数据源的字段绑定到TextBox的Text属性上,应该可以把数据源的字段绑定到BackColor属性上吧。
checked属性绑定,试试1,0

解决方案 »

  1.   

    如下
    textBox1.DataBindings.Add("Text",ds,"Customers.customerID");
    ChecBox.DataBindings.Add("Cheched",ds,"Customers.YesNo");
      

  2.   

    ChecBox.DataBindings.Add("Cheched",ds,"Customers.YesNo");已经实现了,我用的Customers.YesNo是"false"&"true".但ChecBox.DataBindings.Add("BackColor",ds,"MYCOLOR")依旧不正确.
    数据库中的数据是"Color.Blue","Color.Black",System.Drawing的命名空间我已经申明了.
    我也尝试将数据库中的数据改成"Blue","Black",或者是"107, 137, 210",但是一直都是捕获这样的错误类型System.InvalidCastException.搞不懂~
      

  3.   

    有趣的问题 实际上还是蛮简单的 报错是肯定会的因为类型不符 
    解决的方法就是利用Binding.Format event 将数据转换成正确的类型
    Example:
    Table : ID   COLOR
             1   BLACK
             2   WHITE
             3   RED
             4   GREEN
             ....在程序中
    Binding bind = new Binding("BackColor", this.ds, "colors.color")
    bind.Format +=new ConvertEventHandler(ConvertStringToColor);private void ConvertStringToColor(object sender, ConvertEventArgs e){
           if(e.DesiredType == typeof(Color)){
    Color targetColor = Color.FromName((string)e.Value);
    e.Value = targetColor;
           }
    }
    this.label1.DataBindings.Add(bind);---
    DoneParse 和 Format 是Binding类中比较常用的 尤其是显示自定义类型的时候