ComponentOne FlexGrid for WinForms
Step 4 of 5: Allow/Prevent Editing
FlexGrid for WinForms Tutorials > Outline Tutorial > Step 4 of 5: Allow/Prevent Editing

Recall that we set the AllowEditing property of the first column to False. This prevents users from editing any cells in the first column. We would also like to prevent users from entering data in the second column of node rows. To do this, add the following code to handle the BeforeEdit event:

To write code in Visual Basic

Visual Basic
Copy Code
Private Sub C1FlexGrid1_BeforeEdit(ByVal sender As Object, ByVal e As RowColEventArgs) Handles C1FlexGrid1.BeforeEdit
 
    ' If the current row is a node, don't edit it.
    Dim r As Row = C1FlexGrid1.Rows(C1FlexGrid1.Row)
    If r.IsNode Then e.Cancel = True
End Sub

To write code in C#

C#
Copy Code
private void c1FlexGrid1_BeforeEdit( object sender, RowColEventArgs e)
{
    // If the current row is a node, don't edit it.
    Row r = c1FlexGrid1.Rows[c1FlexGrid1.Row];
    if (r.IsNode ) e.Cancel = true;
}
See Also