Back to Devexpress

GridView.EditFormShowing Event

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

latest5.8 KB
Original Source

GridView.EditFormShowing Event

Occurs when an Edit Form is about to be displayed, and allows you to cancel the action.

Namespace : DevExpress.XtraGrid.Views.Grid

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
[DXCategory("Editor")]
public event EditFormShowingEventHandler EditFormShowing
vb
<DXCategory("Editor")>
Public Event EditFormShowing As EditFormShowingEventHandler

Event Data

The EditFormShowing event's data class is EditFormShowingEventArgs. The following properties provide information specific to this event:

PropertyDescription
AllowGets or sets whether opening an Edit Form is allowed.
RowHandleGets the row handle that identifies the grid row for which an Edit Form is opening.

Remarks

You can respond to an Edit Form opening by handling the EditFormShowing event. The EditFormShowingEventArgs class contains information about this event. You can cancel opening an Edit Form by setting the EditFormShowingEventArgs.Allow property to false. To get a handle that identifies a grid row (see Rows) for which an Edit Form is about to be displayed, use the EditFormShowingEventArgs.RowHandle property.

After the EditFormShowing event, the GridView.EditFormPrepared event fires, which allows you to customize the Edit Form.

Example

The following example shows how to prohibit an Edit Form from opening in specific rows.

In this example, the GridView.EditFormShowing event is handled and the Allow event parameter is set to false for orders shipped to France.

csharp
using DevExpress.XtraGrid.Views.Grid;

gridView1.EditFormShowing += new EditFormShowingEventHandler(OnEditFormShowing);
//...
private void OnEditFormShowing(object sender, EditFormShowingEventArgs e) {
    GridView view = sender as GridView;
    if (view == null) return;
    if (view.GetRowCellValue(e.RowHandle, "ShipCountry").ToString() == "France") e.Allow = false;
}
vb
Imports DevExpress.XtraGrid.Views.Grid

AddHandler GridView1.EditFormShowing, AddressOf OnEditFormShowing
'...
Private Sub OnEditFormShowing(sender As Object, e As EditFormShowingEventArgs)
    Dim view As GridView = TryCast(sender, GridView)
    If view Is Nothing Then
        Return
    End If
    If view.GetRowCellValue(e.RowHandle, "ShipCountry").ToString() = "France" Then
        e.Allow = False
    End If
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the EditFormShowing event.

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.

connect-winforms-grid-to-backend-using-middletier-server/CS/WinForms.Client/MainForm.cs#L31

csharp
gridView.PopupMenuShowing += GridView_PopupMenuShowing;
gridView.EditFormShowing += GridView_EditFormShowing;
gridView.CustomRowCellEdit += GridView_CustomRowCellEdit;

connect-winforms-grid-to-backend-using-middletier-server/VB/WinForms.Client/MainForm.vb#L25

vb
AddHandler gridView.PopupMenuShowing, AddressOf GridView_PopupMenuShowing
AddHandler gridView.EditFormShowing, AddressOf GridView_EditFormShowing
gridView.OptionsSelection.EnableAppearanceFocusedCell = False

See Also

EditFormShowingEventArgs

Allow

RowHandle

EditFormPrepared

EditFormHidden

Rows

GridView Class

GridView Members

DevExpress.XtraGrid.Views.Grid Namespace