Back to Devexpress

ColumnView.FocusedRowChanged Event

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-columnview-0ac4b13b.md

latest4.4 KB
Original Source

ColumnView.FocusedRowChanged Event

Fires when the focused row’s handle changes.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
[DXCategory("Property Changed")]
public event FocusedRowChangedEventHandler FocusedRowChanged
vb
<DXCategory("Property Changed")>
Public Event FocusedRowChanged As FocusedRowChangedEventHandler

Event Data

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

PropertyDescription
FocusedRowHandleGets the handle of the currently focused row.
PrevFocusedRowHandleGets the handle of the previously focused row.

Remarks

The FocusedRowChanged event is raised when the ColumnView.FocusedRowHandle property value changes (for example, a user moves row focus, applies sorting/filtering, etc.).

See the following help topic for additional information: Moving Row Focus.

Tip

The view raises the FocusedRowObjectChanged event when another row object is focused.

Note

When focus moves between Master-Detail Views, the FocusedRowChanged event is not raised. The GridControl.FocusedViewChanged event is raised instead.

Example

This example expands a collapsed group row and vice versa when this row receives focus.

csharp
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);
     }
}
vb
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

See Also

BeforeLeaveRow

FocusedRowHandle

FocusedView

FocusedViewChanged

FocusedRowObjectChanged

Example: Focus only Data Rows

FocusedRowChangedEventArgs

ColumnView Class

ColumnView Members

DevExpress.XtraGrid.Views.Base Namespace