Back to Devexpress

EditFormShowingEventArgs.RowHandle Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-editformshowingeventargs-ec770e28.md

latest5.1 KB
Original Source

EditFormShowingEventArgs.RowHandle Property

Gets the row handle that identifies the grid row for which an Edit Form is opening.

Namespace : DevExpress.XtraGrid.Views.Grid

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
public int RowHandle { get; }
vb
Public ReadOnly Property RowHandle As Integer

Property Value

TypeDescription
Int32

The row handle that identifies the grid row for which an Edit Form is opening.

|

Remarks

When you handle the GridView.EditFormShowing event, you can get the row handle that identifies the grid row for which an Edit Form is opening via the RowHandle property. To learn more on how to identify rows, see the Rows topic.

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 snippets (auto-collected from DevExpress Examples) contain references to the RowHandle property.

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-webapi-service/CS/WinForms.Client/MainForm.cs#L31

csharp
e.Allow = false;
var row = gridView1.GetRow(e.RowHandle) as DevExpress.Data.Async.Helpers.ReadonlyThreadSafeProxyForObjectFromAnotherThread;
if(row != null) {

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

csharp
if(gridView.GetRow(e.RowHandle) is Employee employee) {
    using(var editForm = new EditForm(employee, middleTierClient)) {

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

vb
Dim employee As Employee = Nothing
If CSharpImpl.__Assign(employee, TryCast(gridView.GetRow(e.RowHandle), Employee)) IsNot Nothing Then
    Using editForm = New EditForm(employee)

See Also

Rows

Allow

FocusedRowHandle

EditFormShowing

EditFormShowingEventArgs Class

EditFormShowingEventArgs Members

DevExpress.XtraGrid.Views.Grid Namespace