Home Forums WinForms controls Xceed Grid for WinForms Unselect a row Reply To: Unselect a row

Xceed Support
Member
Post count: 5658

This behavior is already implemented. If you are in MultiExtended SelectionMode, by holding the CTRL key, you can unselect a row.

Here is a snippet I used to implement this on the right-click:

e.g.,
<code>
private void Form1_Load( object sender, EventArgs e )
{
//load data

gridControl1.SelectionMode = SelectionMode.MultiExtended;

foreach( Cell cell in dataRowTemplate1.Cells )
{
cell.MouseDown += new MouseEventHandler( cell_MouseDown );
}
}

void cell_MouseDown( object sender, MouseEventArgs e )
{
if( e.Button == MouseButtons.Right )
{
if( ( ( Cell )sender ).ParentRow.IsSelected )
{
gridControl1.SelectedRows.Remove( ( ( Cell )sender ).ParentRow );
}
}
}
</code>

Imported from legacy forums. Posted by CharlesB (had 3061 views)