Datagrid view
-
hi, i am using a datagrid view and one of the column type is datagridviewcheckbox now i need to enable/disable the entire row based on the selection of that checkbox help me pls with regards prasad:)
-
hi, i am using a datagrid view and one of the column type is datagridviewcheckbox now i need to enable/disable the entire row based on the selection of that checkbox help me pls with regards prasad:)
A quick example code. Add this to the CellClick event of the DataGridView.
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 2) { foreach (DataGridViewCell cell in dataGridView1.Rows[e.RowIndex].Cells) { cell.Value = "Nooooo"; } } }
Enabling or disabling a row I don't really know how to do. You should explore the options of DataGridViewCell and DataGridViewRow in the object browser. Let me know when you find it. greetz
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }
-
A quick example code. Add this to the CellClick event of the DataGridView.
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 2) { foreach (DataGridViewCell cell in dataGridView1.Rows[e.RowIndex].Cells) { cell.Value = "Nooooo"; } } }
Enabling or disabling a row I don't really know how to do. You should explore the options of DataGridViewCell and DataGridViewRow in the object browser. Let me know when you find it. greetz
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }
hi, it is filling the rest of the rows with specified value.. but i want to disable/enale that row .. i am trying but not getting help me pls.. with regards prasad:)
-
hi, it is filling the rest of the rows with specified value.. but i want to disable/enale that row .. i am trying but not getting help me pls.. with regards prasad:)
As I said, I don't think it's possible to disable a row in a datagrid. You could set it's ReadOnly property to true, or Frozen.
if (e.ColumnIndex == 2) { // standard value is null, unchecked if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null || (bool)(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex]).Value == false) { dataGridView1.Rows[e.RowIndex].ReadOnly = true; dataGridView1.Rows[e.RowIndex].Frozen = true; // set it to checked dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = true; } else { dataGridView1.Rows[e.RowIndex].ReadOnly = false; dataGridView1.Rows[e.RowIndex].Frozen = false; // set it to unchecked dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = false; } }
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }