method Grid.EditClose ()
Closes the current editor, if the control runs in the edit mode.

 TypeDescription 

Use the EditClose method to close programmatically the current editor. Use the Edit method to start editing a cell. Use the Editing property to check whether the control runs in the edit mode.

The following VB sample closes the editor when user hits 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

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