Skip to main content

Focus row

Comments

5 comments

  • Dapfor Team

    Dear John,

    You can set the focus when a new row is added. Please find the code demonstrating this feature:

    grid.RowAdded += delegate(object sender, GridRowEventArgs e)
    {
        grid.Selection.Clear();
        e.Row.Selected = true;
        e.Row.Focused = true;
        e.Row.EnsureVisible();
    };

     

    Best regards,

    Dapfor

     

    0
  • Hardygun50

    Dear Dapfor, 

    Just found a strange behavior of the custom editor. 

    It can be triggered by first selecting the row and then click the editor on another row. You can see that the first row selection is not cleared. 

    Is it possible to clear the selection even clicking on the editor cell?

    Thanks.

    S.John

     




    Selection.png
    0
  • Dapfor Team

    Dear John,

    There are two different concepts: row focusing and row selection. Only one row can be focused at the time, but multiple rows can be selected. So, the focusing is the grid's property and selection - the row's one. Focused row is used to navigate with keys up/down/pageUp etc...

    To clear the selection of focusing, you can use the following:

     

    //Unselect a single row
    row.Selected = false;

    //You can also clean up all selected rows
    grid.Selection.Clear();

    //How to iterate selected rows:
    foreach (Row row in grid.Selection)
    {
        //do something
    }

    //Remove the focus. Note, focused row won't be removed
    grid.FocusedRow = null;

     

    Now if you need to remove the focus or selection when you edit cells, you have just to have a reference to the grid. The best way to do this is to subscribe for the Grid.CellBeginEdit event:

    grid.CellBeginEdit += delegate(object sender, GridCellBeginEditEventArgs e)
    {
        e.Grid.Selection.Clear();
    };

     

    Best regards,

    Dapfor

    0
  • Hardygun50

    Dear Dapfor, 

    Does it also mean that lasso selection is not supported on the cell with editor ? Thanks.

    S. John

    0
  • Dapfor Team

    Dear John,

    The user can't start lasso selection over editable cells. But if he clicks on non-editable cell or empty space in the row just after the last column or on the row selector (grid.RowSelector.Visible = true) and moves the mouse, then  the grid begins the lasso selection.

    Best regards,

    Dapfor

     

     

    0

Please sign in to leave a comment.

Powered by Zendesk