deselect a row
-
hello, I want to deselect a row in the datagridview, and I'm using the code:
if ( dgv[ hti.ColumnIndex, hti.RowIndex ].Selected ) { dgv[ hti.ColumnIndex, hti.RowIndex ].Selected = false; } else { dgv[ hti.ColumnIndex, hti.RowIndex ].Selected = true; }
this code is in the DatagridView_MouseClick. the code does not work, anybody knows why? thank you -
hello, I want to deselect a row in the datagridview, and I'm using the code:
if ( dgv[ hti.ColumnIndex, hti.RowIndex ].Selected ) { dgv[ hti.ColumnIndex, hti.RowIndex ].Selected = false; } else { dgv[ hti.ColumnIndex, hti.RowIndex ].Selected = true; }
this code is in the DatagridView_MouseClick. the code does not work, anybody knows why? thank youFirst of all you could have written this like this:
dgv[ hti.ColumnIndex, hti.RowIndex ].Selected=!(dgv[ hti.ColumnIndex, hti.RowIndex ].Selected);
Secondly, if the row is not selected it will become selected. Do you want this to happen? -
hello, I want to deselect a row in the datagridview, and I'm using the code:
if ( dgv[ hti.ColumnIndex, hti.RowIndex ].Selected ) { dgv[ hti.ColumnIndex, hti.RowIndex ].Selected = false; } else { dgv[ hti.ColumnIndex, hti.RowIndex ].Selected = true; }
this code is in the DatagridView_MouseClick. the code does not work, anybody knows why? thank youYou can use
ClearSelection
function of DataGridView -
hello, I want to deselect a row in the datagridview, and I'm using the code:
if ( dgv[ hti.ColumnIndex, hti.RowIndex ].Selected ) { dgv[ hti.ColumnIndex, hti.RowIndex ].Selected = false; } else { dgv[ hti.ColumnIndex, hti.RowIndex ].Selected = true; }
this code is in the DatagridView_MouseClick. the code does not work, anybody knows why? thank you -
Hi, this also works dgv[ hti.ColumnIndex, hti.RowIndex ].SelectedIndex = -1
rAm i Think, i Wait, i Fast -- Siddartha
the "SelectedIndex" does not exist in this case.