在DataGridView里面又一列Button和一列TextBox框。我现在想在一些条件下设置Button为非活性,TextBox框的内容为灰色。请问该怎末实现?PS:
http://blog.csdn.net/yanwei100/article/details/780418
根据上面方法是设置DataGridView里所有内容都是Button,不符合要求。我想按照不同列设置不同内容,那样太复杂。请问有没有简单的方法?

解决方案 »

  1.   

    为什么不行啊?
    列的ColumnType设置为DataGridViewButtonColumn就可以了
      

  2.   

    RowDataBound里面 根据条件或者数据来显示。之类的 例子
    /判断当前行是否是数据行
    DataRowView drv = e.Row.DataItem as DataRowView;//获取所有数据
             if (e.Row.RowType == DataControlRowType.DataRow)         {   //用FindControl方法找到模板中的Label控件Label lb1= (Label)e.Row.FindControl("Label1");//因为RowDataBound是发生在数据绑定之后,所以我们可以//判断Label绑定的数据,如果是True,就更改其text属性为男                 if (lb1.Text== "True")
                           lb1.Text = "男";
                     else
                           lb1.Text = "female";         }