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 following edit-related events are triggered in this sequence:

  1. Edit event, This event is raised before the editing process begins. It allows you to prevent the cell from being edited by setting the Cancel parameter to True.
  2. EditOpen event, Triggered once the editing process starts and the editor is displayed. The Editing property returns the handle of the internal editor window being used.
  3. Change event, Fired just before the cell's content is about to change. The NewValue parameter contains the new value that will be assigned to the cell, while the CellValue property holds the current value. If the control is linked to a database, note that the corresponding database field remains unchanged at the time the Change event is triggered.
  4. Changed event, Occurs after the user has successfully changed the content of the cell. The CellValue property now reflects the updated value. If the control is linked to a database, the corresponding field is updated, so the new value is available during the Changed event.
  5. EditClose event, Raised when the cell editor is closed and no longer visible.

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