windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-focusedrowchangedeventargs-0e0c34a0.md
Gets the handle of the previously focused row.
Namespace : DevExpress.XtraGrid.Views.Base
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
public int PrevFocusedRowHandle { get; }
Public ReadOnly Property PrevFocusedRowHandle As Integer
| Type | Description |
|---|---|
| Int32 |
An integer value representing the handle of the previously focused row. The GridControl.InvalidRowHandle field value if no row was previously focused.
|
This example expands a collapsed group row and vice versa when this row receives focus.
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Base;
private void gridView1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e) {
GridView view = sender as GridView;
if (view == null) return;
if (view.IsGroupRow(e.FocusedRowHandle)) {
bool expanded = view.GetRowExpanded(e.FocusedRowHandle);
view.SetRowExpanded(e.FocusedRowHandle, !expanded);
}
}
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid.Views.Base
Private Sub GridView1_FocusedRowChanged(ByVal sender As System.Object, _
ByVal e As FocusedRowChangedEventArgs) Handles GridView1.FocusedRowChanged
Dim view As GridView = sender
If view Is Nothing Then
Return
End If
If view.IsGroupRow(e.FocusedRowHandle) Then
Dim expanded As Boolean = view.GetRowExpanded(e.FocusedRowHandle)
view.SetRowExpanded(e.FocusedRowHandle, Not expanded)
End If
End Sub
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the PrevFocusedRowHandle 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.
winforms-grid-prevent-focusing-group-row/CS/Form1.cs#L33
{
if (e.PrevFocusedRowHandle == GridControl.InvalidRowHandle)
focusedRowHandle = 0;
winforms-grid-prevent-focusing-group-row/VB/Form1.vb#L31
If e.FocusedRowHandle < 0 Then
If e.PrevFocusedRowHandle = GridControl.InvalidRowHandle Then
focusedRowHandle = 0
See Also
FocusedRowChangedEventArgs Class