property Grid.Editing as Long
Specifies the window's handle of the built-in editor while the control is running in edit mode.

 TypeDescription 
   Long A long expression that indicates the window's handle for the built-in editor that's focused while the control is running in the edit mode.  

Use the Editing property to check whether the control is in edit mode.  Use the Editing property to get the window's handle for the built-in editor while editing.  Use the Edit method to start editing the focused cell. Use the EditType property to define the column's editor. Use the ReadOnly property to make the control read only. Call the EditClose method to close the current editor. The EditingText property returns the caption being shown on the editor while the control runs in edit mode. The Editing property returns a not-zero value only if called during the EditOpen, Change or EditClose event.

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.

The following VB sample closes the current editor if the user presses the enter key:

Private Sub Grid1_KeyDown(KeyCode As Integer, Shift As Integer)
    With Grid1
        If Not (.Editing = 0) Then
            If (KeyCode = vbKeyReturn) Then
                .EditClose
                KeyCode = 0
            End If
        End If
    End With
End Sub

The following C++ sample closes the editor when user hits the enter key:

void OnKeyDownGrid1(short FAR* KeyCode, short Shift) 
{
	if ( *KeyCode == VK_RETURN )
		if ( m_grid.GetEditing() != 0 )
		{
			m_grid.EditClose();
			*KeyCode = 0;
		}
}

The following C# sample closes the editor when user hits the enter key:

private void axGrid1_KeyDownEvent(object sender, AxEXGRIDLib._IGridEvents_KeyDownEvent e)
{
	if (Convert.ToUInt32(e.keyCode) == Convert.ToUInt32(Keys.Enter))
		if (axGrid1.Editing != 0)
		{
			axGrid1.EditClose();
			e.keyCode = 0;
		}
}

The following VB.NET sample closes the editor when user hits the enter key:

Private Sub AxGrid1_KeyDownEvent(ByVal sender As Object, ByVal e As AxEXGRIDLib._IGridEvents_KeyDownEvent) Handles AxGrid1.KeyDownEvent
    If (Convert.ToUInt32(e.keyCode) = Convert.ToUInt32(Keys.Enter)) Then
        With AxGrid1
            If Not (.Editing = 0) Then
                .EditClose()
                e.keyCode = 0
            End If
        End With
    End If
End Sub

The following VFP sample closes the editor when user hits the enter key:

*** ActiveX Control Event ***
LPARAMETERS keycode, shift

if ( keycode = 13 ) &&vkReturn
	with thisform.Grid1.Object
		if ( .Editing() != 0 )
			.EditClose()
			keycode = 0
		endif
	endwith
endif

If your application still requires the string that user types into an text box inside the exGrid control. you can use the following VB trick:

The sample requires the following API declarations:

The following C++ sample displays a message box with the caption that user types inside the text box of an editor:

 

 


Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.