DataGird與datasource
綁定,其中已經有一些checked
和unchecked
值。我必須禁用其值被檢查的按鈕。DataGridView在勾選的值上,禁用按鈕
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;
}
}
}
那麼你面臨的問題是什麼? – V4Vendetta
我不能訪問btn.Enabled = false屬性。按鈕如何禁用? – huda
也許你可以用一個'DataGridViewTextBoxCell'來替換單元格,並給出一個禁用的'BackColor',它應該足夠好! – V4Vendetta