Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我想基于C#datagridview中的checkboxColumn使单个textbox单元格可读_C#_.net_User Interface_Checkbox_Datagridview - Fatal编程技术网

我想基于C#datagridview中的checkboxColumn使单个textbox单元格可读

我想基于C#datagridview中的checkboxColumn使单个textbox单元格可读,c#,.net,user-interface,checkbox,datagridview,C#,.net,User Interface,Checkbox,Datagridview,我想根据 复选框。如果选中复选框,则rextbox是可写的 private void dgvItem_CellValueChanged(对象发送方,DataGridViewCellEventArgs e) {bool valid=Convert.ToBoolean(this.dgvItem.CurrentRow.Cells[0].Value.ToString());//空引用异常 如果(有效) { this.dgvItem.CurrentRow.Cells[3]。只读=false; } }Cu

我想根据 复选框。如果选中复选框,则rextbox是可写的

private void dgvItem_CellValueChanged(对象发送方,DataGridViewCellEventArgs e)
{bool valid=Convert.ToBoolean(this.dgvItem.CurrentRow.Cells[0].Value.ToString());//空引用异常
如果(有效)
{
this.dgvItem.CurrentRow.Cells[3]。只读=false;
}

}
CurrentRow可以为null,或者单元格值可以为null。 使用以下代码

private void dgvItem_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
    //if column 0 is the checkbox column, then execute the code only for it
    if (e.ColumnIndex == 0) 
    {
        bool valid = Convert.ToBoolean(Convert.ToString(this.dgvItem.Rows[e.RowIndex].Cells[e.ColumnIndex].Value));
        this.dgvItem.Rows[e.RowIndex].Cells[3].ReadOnly = !valid;
    }
}
这是下列文件的副本: