Flexgrid lock Cell

Posted by: saidnai on 20 December 2022, 11:30 am EST

    • Post Options:
    • Link

    Posted 20 December 2022, 11:30 am EST

    Hi all,

    I need to go through the flexgrid and lock all the cell from editiong if it contains an amount/number. I used the bellow code in VB but it does not work and hope you can support.

    Best regards

    Said

    Private Sub CellBlock()
        Try
            If IsNothing(Flexgrid.DataSource) Then
                Exit Sub
            Else
                Dim ycount As Int32 = DirectCast(Flexgrid.DataSource, DataTable).Rows.Count
                If ycount > 0 Then
                    Dim rw As Integer = 0
                    For Each r As Row In Flexgrid.Rows
                        If rw = 0 Then
                            rw += 1
                        Else
                            If Flexgrid(rw, 6) Is DBNull.Value Or GetValue(Flexgrid(rw, 6)) = 0 Then
                            Else
                                Flexgrid(rw, 6).allowediting = False
                            End If
                            rw += 1
                        End If
                    Next
                End If
            End If
    
        Catch ex As Exception
            MsgBox("Error 'CellBlock' : " & vbCrLf & ex.ToString, MsgBoxStyle.Critical)
        End Try
    End Sub
    
  • Posted 21 December 2022, 2:12 am EST

    Hi Said,

    To lock the editing of C1FlexGrid cells, you can handle the BeforeEdit event of the C1FlexGrid. In the event, you can check for the cell’s value and cancel the editing accordingly. Please see the attached sample for reference.

    Attachment: LockCell_Fg.zip

    Best Regards,

    Kartik

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels