FlexGrid for WinForms | ComponentOne
Edit / Disable Editing
In This Topic
    Disable Editing
    In This Topic

    FlexGrid, by default, allows end-user to edit the cell values at runtime. However, with FlexGrid, you can easily manage how much control you want to give to the end-users using various properties provided by the FlexGrid.

    Disable Grid Editing

    To disable editing of the whole WinForms FlexGrid, you need to set AllowEditing property of the C1FlexGrid class to false as shown in the code below.

     // Disable grid editing 
     c1FlexGrid1.AllowEditing = false;
    
    ' Disable grid editing 
    c1FlexGrid1.AllowEditing = False      
    

    Disable Row or Column Editing

    To disable the editing of a particular row or column of the WinForms FlexGrid, you can set the AllowEditing property of Row or Column object to false as shown in the code below.

    // Disable editing of third row
    c1FlexGrid1.Rows[3].AllowEditing = false;
                                            
    // Disable editing of third column
    c1FlexGrid1.Cols[3].AllowEditing = false;
    
    ' Disable editing of third row
    c1FlexGrid1.Rows(3).AllowEditing = False
    
    ' Disable editing of third column
    c1FlexGrid1.Cols(3).AllowEditing = False      
    

    Disable Cell Editing

    To disable editing of a particular cell, you can use the BeforeEdit event and set the Cancel parameter for that particular cell to true.

    // Disable cell editing 
    private void C1FlexGrid1_BeforeEdit(object sender, RowColEventArgs e)
       {
         if ((e.Col == 4) && (e.Row == 2))
          {
              e.Cancel = true;
          }
       }                          
    
    ' Disable cell editing 
    Private Sub C1FlexGrid1_BeforeEdit(ByVal sender As Object, ByVal e As RowColEventArgs)
        If e.Col = 4 AndAlso e.Row = 2 Then
            e.Cancel = True
        End If
    End Sub