Home Forums WinForms controls Xceed Grid for WinForms Unselect a row

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15813 |

    When a user click on a row, the row becomes selected. I want the user to be able to click the row again to unselect it. Right now the only way to unselect a row is to click on another row. How can I do that?

    Imported from legacy forums. Posted by Robert (had 2048 views)

    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)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.