Back to Devexpress

GridView.ShowEditor() Method

windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridview-f87fcf7d.md

latest8.3 KB
Original Source

GridView.ShowEditor() Method

Invokes the focused cell’s editor.

Namespace : DevExpress.XtraGrid.Views.Grid

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
public override void ShowEditor()
vb
Public Overrides Sub ShowEditor

Remarks

The method is called automatically when users invoke a cell editor. You can also call this method manually. If you want to activate a particular cell’s editor, you need to focus the cell first. Use the ColumnView.FocusedRowHandle and ColumnView.FocusedColumn properties for this purpose.

Note : a cell editor cannot be activated (the user cannot edit the focused cell’s value) in the following cases:

Refer to the Modify and Validate Cell Values topic for additional information.

Note

Detail pattern Views do not contain data and they are never displayed within XtraGrid. So, the ShowEditor member must not be invoked for these Views. The ShowEditor member can only be used with Views that display real data within the Grid Control. Use the following methods to access these Views with which an end user interacts at runtime.

The code sample below illustrates how to activate a cell editor for the “Product Price” column when when they press F12.

csharp
gridView1.KeyDown += GridView1_KeyDown;

private void GridView1_KeyDown(object sender, KeyEventArgs e)
{
    if(e.KeyCode == Keys.F12)
    {
        GridView view = sender as GridView;
        view.FocusedColumn = view.Columns["productPrice"];
        view.ShowEditor();
        e.Handled = true;
    }
}
vb
Private gridView1.KeyDown += AddressOf GridView1_KeyDown

Private Sub GridView1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
    If e.KeyCode = Keys.F12 Then
        Dim view As GridView = TryCast(sender, GridView)
        view.FocusedColumn = view.Columns("productPrice")
        view.ShowEditor()
        e.Handled = True
    End If
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the ShowEditor() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-grid-toggle-checkbox-state-with-one-click/CS/Form1.cs#L65

csharp
view.FocusedRowHandle = hi.RowHandle;
view.ShowEditor();
CheckEdit edit = view.ActiveEditor as CheckEdit;

winforms-grid-auto-expand-new-master-row/CS/Q205071/Form1.cs#L62

csharp
gridControl1.FocusedView = childView;
    childView.ShowEditor();
}

winforms-grid-show-context-menu-for-rows/CS/FormGridMenu.cs#L28

csharp
GridHitInfo info = GetHitInfo(e.Link);
    info?.View.ShowEditor();
}

winforms-grid-change-checkbox-state-single-click-in-multi-select-mode/CS/Form1.cs#L46

csharp
gridView1.FocusedRowHandle = hitInfo.RowHandle;
gridView1.ShowEditor();
CheckEdit edit = gridView1.ActiveEditor as CheckEdit;

winforms-grid-single-button-click-multiple-selection/CS/WindowsApplication168/Form1.cs#L43

csharp
view.FocusedColumn = hi.Column;
view.ShowEditor();
//force button click

winforms-grid-toggle-checkbox-state-with-one-click/VB/Form1.vb#L58

vb
view.FocusedRowHandle = hi.RowHandle
view.ShowEditor()
Dim edit As CheckEdit = TryCast(view.ActiveEditor, CheckEdit)

winforms-grid-auto-expand-new-master-row/VB/Q205071/Form1.vb#L64

vb
gridControl1.FocusedView = childView
    childView.ShowEditor()
End Sub

winforms-grid-show-context-menu-for-rows/VB/FormGridMenu.vb#L29

vb
Dim info = GetHitInfo(e.Link)
    info?.View.ShowEditor()
End Sub

winforms-grid-change-checkbox-state-single-click-in-multi-select-mode/VB/Form1.vb#L40

vb
gridView1.FocusedRowHandle = hitInfo.RowHandle
gridView1.ShowEditor()
Dim edit As CheckEdit = TryCast(gridView1.ActiveEditor, CheckEdit)

winforms-grid-single-button-click-multiple-selection/VB/WindowsApplication168/Form1.vb#L36

vb
view.FocusedColumn = hi.Column
view.ShowEditor()
'force button click

See Also

HideEditor()

PostEditor()

CanShowEditor

ActiveEditor

GridView Class

GridView Members

DevExpress.XtraGrid.Views.Grid Namespace