у меня ошибка
Невозможно привести объект типа «System.Windows.Forms.DataGridViewButtonCell» к типу «Sento.DataGridViewDisableButtonCell». '
Моя цель состоит в том, чтобы при установке флажка ячейки кнопка включала
Мой код:
private void GrdSento_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if(GrdSento.Columns[e.ColumnIndex].Name == "Check")
{
DataGridViewCheckBoxCell checkBoxCell = (DataGridViewCheckBoxCell)GrdSento.Rows[e.RowIndex].Cells["Check"];
DataGridViewDisableButtonCell ButtonCell = (DataGridViewDisableButtonCell)GrdSento.Rows[e.RowIndex].Cells["Edit"];
ButtonCell.Enabled = !(Boolean)checkBoxCell.Value;
GrdSento.Invalidate();
}
}
Копирую по этой ссылке: DataGridViewDisableButtonCell
public class DataGridViewDisableButtonCell : DataGridViewButtonCell
{
private bool enabledValue;
public bool Enabled
{
get
{
return enabledValue;
}
set
{
enabledValue = value;
}
}
// By default, enable the button cell.
public DataGridViewDisableButtonCell()
{
this.enabledValue = true;
}
}
DataGridViewDisableButtonCell уже унаследован от DataGridViewButtonCell, но все равно получает ошибку. Пожалуйста, помогите мне.