ComponentOne VSFlexGrid 8.0
BeforeRowColChange Event

Fired before the current cell (Row, Col) changes to a different cell.

Syntax

Private Sub VSFlexGrid_BeforeRowColChange( ByVal OldRow As Long,  ByVal OldCol As Long,  ByVal NewRow As Long,  ByVal NewCol As Long, Cancel As Boolean)

Remarks

This event gets fired before the Row and Col properties change, either as a result of user actions or through code. It allows you to prevent the selection of certain cells, thus creating "protected" ranges on a grid.

BeforeRowColChange It is fired only when the Row and Col property are about to change. To prevent the extended selection of a range, you also need to handle the BeforeSelChange event.

For example, the following code creates a protected range with a green background and prevents the user from selecting any cells on the protected range and from extending any selections into the protected area:

    ' highlight protected range

    Private Sub Form_Load()

        fg.Cell(flexcpBackColor, 2, 2, 8, 4) = RGB(200, 250, 200)

    End Sub

    ' cancel if new cell is in protected area

    Private Sub fg_BeforeRowColChange(ByVal OldRow As Long, ByVal OldCol As Long, _

                                      ByVal NewRow As Long, ByVal NewCol As Long, Cancel As Boolean)

        If NewRow >= 2 And NewRow <= 8 And NewCol >= 2 And NewCol <= 4 Then Cancel = True

    End Sub

    ' cancel if new selection is on protected area

    Private Sub fg_BeforeSelChange(ByVal OldRowSel As Long, ByVal OldColSel As Long, _

                                   ByVal NewRowSel As Long, ByVal NewColSel As Long, Cancel As Boolean)

        If (fg.Row < 2 And NewRowSel < 2) Or (fg.Col < 2 And NewColSel < 2) Then Exit Sub

        If (fg.Row > 8 And NewRowSel > 8) Or (fg.Col > 4 And NewColSel > 4) Then Exit Sub

        Cancel = True

    End Sub

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback