BeforeEdit Event

Fired before the control enters cell edit mode.

Syntax

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

Remarks

This event is fired before the control enters edit mode and before an editable cell is repainted when it has the focus. 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 BeforeEdit event.

The parameters for the BeforeEdit 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.

Because BeforeEdit is fired before each repaint, it does not guarantee that the control is really about to enter edit mode. For that, use the StartEdit event instead. 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