WinUI | ComponentOne
Controls / FlexGrid / Row / User Interaction
In This Topic
    User Interaction
    In This Topic

    This topic discusses how you can let end-users interact with the FlexGrid rows.

    Allow Dragging

    FlexGrid, by default, does not allow user to rearrange rows by dragging. However, you can change this behavior in unbound grid by using the FlexGrid.AllowDragging property. To enable dragging of grid rows, you can set the FlexGrid.AllowDragging property to either Rows or Both. This property accepts the values from GridAllowDragging enumeration.

    Following code shows how to allow users to drag the FlexGrid rows at run-time.

    C#
    Copy Code
    // Allow Dragging
    flexGrid1.AllowDragging = GridAllowDragging.Rows;
    

    Allow Resizing

    By default, FlexGrid does not give option to resize the rows. To change this behavior, you can use AllowResizing property of the FlexGrid class. This property accepts values from the GridAllowResizing enumeration, which enables end-user to change size of columns, rows or both.

    Following code shows how to allow users to resize the FlexGrid rows at run-time.

    C#
    Copy Code
    // Allow Resizing
    flexGrid1.AllowResizing = GridAllowResizing.Rows;
    
    Note: Dragging and Resizing are only valid at the position in the row selector.

    Disable Row Editing

    To disable a row from getting edited at runtime, set the IsReadOnly property of GridRow class to true.

    C#
    Copy Code
    // Disable Row Editing
    flexGrid1.Rows[2].IsReadOnly = true;
    

    You can also prevent editing in a particular row using the BeginningEdit event of the FlexGrid class that triggers when the row editing is about to start.

    Observe the code below to use the BeginningEdit event in your WinUI application. For example, editing is disabled in the second row in the example code below.

    C#
    Copy Code
    public Rows()
     {        
         flexGrid1.BeginningEdit += FlexGrid1_BeginningEdit;
     }
    private void FlexGrid1_BeginningEdit(object sender, GridCellEditEventArgs e)
     {
         if (e.CellRange.Row == 2)
          e.Cancel = true;
     }