Row select on DataGridView
-
Hey guys I have a datagridview populated with entries from a database. I have set the selection mode of the grid to fullrowselect so that a click on any cell will cause selection of that row. In this selection event I open a new form showing the data contained in that row. This works fine, however when you click on a column header it still tries to select that row. Is there any way of stopping this? Thanks in advance
-
Hey guys I have a datagridview populated with entries from a database. I have set the selection mode of the grid to fullrowselect so that a click on any cell will cause selection of that row. In this selection event I open a new form showing the data contained in that row. This works fine, however when you click on a column header it still tries to select that row. Is there any way of stopping this? Thanks in advance
What event are you using? I used the doubleClick event somewhere in an old app, and it just refers to the SelectedItem in the datagrid. Then if you doubleclick the header, it just opens the record that was selected last.
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }
-
What event are you using? I used the doubleClick event somewhere in an old app, and it just refers to the SelectedItem in the datagrid. Then if you doubleclick the header, it just opens the record that was selected last.
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }
-
I was using the selectionChanged event of the datagrid, is there anyway of knowing which row the selection was made on? ie if row is header row type then do nothing?
you could use an event like CellClick or RowEnter, they have DataGridViewCellEventArgs where you can access the ColumnIndex and the RowIndex of the selection.
private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e) { // e.RowIndex // e.ColumnIndex }
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }
-
you could use an event like CellClick or RowEnter, they have DataGridViewCellEventArgs where you can access the ColumnIndex and the RowIndex of the selection.
private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e) { // e.RowIndex // e.ColumnIndex }
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }