event EditOpen ()
Occurs when edit operation starts.

TypeDescription

Use the EditOpen event to notify your application that the cell's editor is shown and ready to edit the cell. The Editing specifies the window's handle of the built-in editor while the control is running in edit mode. The EditingText property returns the caption being shown on the editor while the control runs in edit mode.

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.

Syntax for EditOpen event, /NET version, on:

private void EditOpen(object sender)
{
}

Private Sub EditOpen(ByVal sender As System.Object) Handles EditOpen
End Sub

Syntax for EditOpen event, /COM version, on:

private void EditOpen(object sender, EventArgs e)
{
}

void OnEditOpen()
{
}

void __fastcall EditOpen(TObject *Sender)
{
}

procedure EditOpen(ASender: TObject; );
begin
end;

procedure EditOpen(sender: System.Object; e: System.EventArgs);
begin
end;

begin event EditOpen()
end event EditOpen

Private Sub EditOpen(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EditOpen
End Sub

Private Sub EditOpen()
End Sub

Private Sub EditOpen()
End Sub

LPARAMETERS nop

PROCEDURE OnEditOpen(oGrid)
RETURN

Syntax for EditOpen event, /COM version (others), on:

<SCRIPT EVENT="EditOpen()" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function EditOpen()
End Function
</SCRIPT>

Procedure OnComEditOpen 
	Forward Send OnComEditOpen 
End_Procedure

METHOD OCX_EditOpen() CLASS MainDialog
RETURN NIL

void onEvent_EditOpen()
{
}

function EditOpen as v ()
end function

function nativeObject_EditOpen()
return

The following VB sample unselects the text when the editor is opened ( in case the editor is an edit control ) ( by default, the control selects the text when editor is opened ). The following VB sample unselects the text when the editor is opened, by sending an EM_SETSEL message to the cell's edit control:

Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const EM_SETSEL = &HB1

Private Sub Grid1_EditOpen()
    PostMessage Grid1.Editing, EM_SETSEL, 0, 0
End Sub

The following C++ sample unselects the text, when the editor is opened ( in case the editor is an edit control ):

void OnEditOpenGrid1() 
{
	::PostMessage( (HWND)m_grid.GetEditing(), EM_SETSEL, 0, 0 );
}
The following VB sample determines the handle of the edit control, without using the Editing property. 

Private Function getEditWnd(ByVal g As EXGRIDLibCtl.Grid) As Long
    Dim h As Long
    h = GetWindow(g.hwnd, GW_CHILD)
    While Not (h = 0)
        If (getWndClass(h) = "HolderBuiltIn") Then
                getEditWnd = GetWindow(h, GW_CHILD)
            Exit Function
        End If
        h = GetWindow(h, GW_HWNDNEXT)
    Wend
    getEditWnd = 0
End Function

Private Function getWndClass(ByVal h As Long) As String
    Dim s As String
    s = Space(1024)
    GetClassName h, s, 1024
    getWndClass = To0(s)
End Function

Private Function To0(ByVal s As String) As String
    To0 = Left$(s, InStr(s, Chr$(0)) - 1)
End Function

Private Sub Grid1_EditOpen()
    PostMessage getEditWnd(Grid1), EM_SETSEL, 0, 0
End Sub

The VB sample requires the following declarations:

Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Const GW_CHILD = 5
Private Const GW_HWNDNEXT = 2
Private Const EM_SETSEL = &HB1