method Grid.Edit ([Options as Variant])
Edits the focused cell.

Options as Variant Optional. If missing, the control edits the focused cell. A long expression that indicates the handle of a locked item. Use the LockedItem property to retrieve the handle of a locked/fixed item.

The Edit method starts editing the focused cell, if the cell has an editor assigned. Use the Editor property of the Column object, or CellEditor property to assign an editor to a cell. The focused cell is determined by the intersection of the focused item and the focused column. Use the FocusItem property to get the handle of the focused item. Use the FocusColumnIndex property to determine the index of the focused column. The control fires the Edit event when the edit operation is about to start. The edit operation doesn't start if the control's ReadOnly property is True, or if the cell's editor is hidden ( CellEditorVisible property is False ). Use the Editing property to check whether the control is in edit mode, or to get the window's handle for the built-in editor that's visible and focused. The EditClose method closes the current editor. Use the ValidateValue event to validate the values that user enters.  

The edit events are fired in the following order:

  1. Edit event. Prevents editing cells, before showing the cell's editor.

  2. EditOpen event. The edit operation started, the cell's editor is shown. The Editing property gives the window's handle of the built-in editor being started.

  3. Change event. The Change event is fired only if the user types ENTER key, or the user selects a new value from a predefined data list.

  4. EditClose event. The cell's editor is hidden and closed.

If the Options parameter is missing, the control edits the focused cell. The FocusItem and FocusColumnIndex properties indicates the focused cell. If the Options parameter is present, the control edits the item that Options parameter indicates.

For instance, the following VB sample edits a locked item when the user clicks a cell:

Private Sub Grid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    With Grid1
        If Button = 1 Then
            Dim h As EXGRIDLibCtl.HITEM, c As Long, hit As EXGRIDLibCtl.HitTestInfoEnum
            h = .ItemFromPoint(X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY, c, hit)
            If Not h = 0 Then
                If (.Items.IsItemLocked(h)) Then
                     .FocusColumnIndex = c
                     .Edit h
                End If
            End If
        End If
    End With
End Sub

Call the DoEvents (Processes all Windows messages currently in the message queue) method after Edit method to start immediately the edit operation.

The following C++ sample edits edits a locked item when the user clicks a cell:

void OnMouseUpGrid1(short Button, short Shift, long X, long Y) 
	CItems items = m_grid.GetItems();
	long c = 0, hit = 0, h = m_grid.GetItemFromPoint( X, Y, &c, &hit);
	if ( h != 0 )
		if ( items.GetIsItemLocked( h ) )
			m_grid.SetFocusColumnIndex( c );
			m_grid.Edit( COleVariant( h ) );

The following VB.NET sample edits edits a locked item when the user clicks a cell:

Private Sub AxGrid1_MouseUpEvent(ByVal sender As Object, ByVal e As AxEXGRIDLib._IGridEvents_MouseUpEvent) Handles AxGrid1.MouseUpEvent
    With AxGrid1
        Dim i As Integer, c As Integer, hit As EXGRIDLib.HitTestInfoEnum
        i = .get_ItemFromPoint(e.x, e.y, c, hit)
        If (Not (i = 0)) Then
            If (.Items.IsItemLocked(i)) Then
                 .FocusColumnIndex = c
            End If
        End If
    End With
End Sub

The following C# sample edits edits a locked item when the user clicks a cell:

private void axGrid1_MouseUpEvent(object sender, AxEXGRIDLib._IGridEvents_MouseUpEvent e)
	int c = 0;
	EXGRIDLib.HitTestInfoEnum hit;
	int i = axGrid1.get_ItemFromPoint(e.x, e.y, out c, out hit);
	if (i != 0)
		if ( axGrid1.Items.get_IsItemLocked( i ) )
				axGrid1.FocusColumnIndex = c;

The following VFP sample edits edits a locked item when the user clicks a cell:

*** ActiveX Control Event ***
LPARAMETERS button, shift, x, y

local c, hit
c = 0
hit = 0
with thisform.Grid1
	.Items.DefaultItem = .ItemFromPoint( x, y, @c, @hit )
	if ( .Items.DefaultItem <> 0 )
		if ( .Items.IsItemLocked(0) ) 
			.FocusColumnIndex = c