StartEdit Event

Fired when the control enters cell edit mode (after BeforeEdit).

Syntax

Private Sub VSFlexGrid_StartEdit( ByVal Row As Long, ByVal Col As Long, Cancel As Boolean)

Remarks

This event is fired before the control enters edit mode. It allows you to prevent editing by setting the Cancel parameter to True, to supply a list of choices for a combo list with the ComboList property, or to specify an edit mask with the EditMask property.

If the choices or the mask are the same for a whole column, you may set them with the ColComboList and ColEditMask properties, and you don't need to handle the StartEdit event.

The parameters for the StartEdit event are described below:

Row As Long, Col As Long

Indicate which cell is about to be edited or repainted.

Cancel As Boolean

Allows you to cancel the editing operation.

The difference between the BeforeEdit and StartEdit events is that the former gets fired every time the current cell is repainted, and does not guarantee that the control is really about to enter edit mode. The StartEdit event, on the other hand, is only fired when the cell is about to enter edit mode.

The following code sets the grid to show a different background color for the cell that is currently being edited:

    Private Sub fg_StartEdit(ByVal Row As Long, ByVal Col As Long, Cancel As Boolean)

   

        fg.CellBackColor = vbYellow

       

    End Sub

   

    Private Sub fg_AfterEdit(ByVal Row As Long, ByVal Col As Long)

   

        fg.CellBackColor = vbDefault

       

    End Sub

If the user starts editing by pressing a key, several events get fired in the following sequence:

KeyDown 65        ' user pressed the 'a' key (65 = 'A')

BeforeEdit 1  1   ' allows you to cancel the editing

StartEdit 1 1     ' not canceled, edit is about to start

KeyPressEdit 97   ' 'a' key passed to editor (97 = 'a')

KeyUpEdit 65      ' user released the key

KeyDownEdit 13    ' user pressed Enter

ValidateEdit      ' allows you to validate the edit

AfterEdit  1  1   ' editing done

BeforeEdit 1  1   ' repainting cell

KeyUp 13          ' user released ENTER key

See Also

VSFlexGrid Control