DataGridView在选中的值上,禁用按钮

时间:2012-08-24 06:41:30

标签: c# datagridview

DataGrid与已datasourcechecked值的unchecked绑定。我必须禁用其值已选中的按钮。

    private void disableManualBuyButtons()
    {
        foreach (DataGridViewRow row in gvViewTickets.Rows)
        {
            DataGridViewCheckBoxCell cbc = (DataGridViewCheckBoxCell)row.Cells[0];
            cbc.TrueValue = true;
            if (cbc.Value.Equals(cbc.TrueValue))
            {
                DataGridViewButtonCell btn = (DataGridViewButtonCell)row.Cells[8];
                btn.ReadOnly = true;
            }
        }
    }

1 个答案:

答案 0 :(得分:1)

根据this文章:

  

DataGridView控件包含DataGridViewButtonCell类,用于显示具有用户界面(UI)的单元格,如按钮。但是,DataGridViewButtonCell不提供禁用单元格显示按钮外观的方法。

文章建议的解决方法是创建自己的列。你会在文章中找到完整的代码。

相关问题