Back to Devexpress

VGridControlBase.FocusedRecordChanged Event

windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridcontrolbase-9a78d720.md

latest3.5 KB
Original Source

VGridControlBase.FocusedRecordChanged Event

Fires in response to record focus changing.

Namespace : DevExpress.XtraVerticalGrid

Assembly : DevExpress.XtraVerticalGrid.v25.2.dll

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

Declaration

csharp
public event IndexChangedEventHandler FocusedRecordChanged
vb
Public Event FocusedRecordChanged As IndexChangedEventHandler

Event Data

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

PropertyDescription
NewIndexGets the index of the currently focused element.
OldIndexGets the index of the previously focused element.

Remarks

The FocusedRecordChanged event is raised when an end-user moves focus from one record to another or after the VGridControlBase.FocusedRecord property’s value has been changed in code. This can occur in the cases listed below:

  • focus moves from cell to cell if the previously and currently focused cells belong to different records;
  • a record is focused after no record was focused;
  • the focused record has been deleted.

Example

The following sample code handles the VGridControlBase.FocusedRecordChanged event to obtain the currently and previously focused records in order to display the record selection sequence and the number of total records in the status bar sections.

Note : you need to place a StatusBar control on a Form.

The image below shows the result:

csharp
using DevExpress.XtraVerticalGrid.Events;

private void vGridControl1_FocusedRecordChanged(object sender, IndexChangedEventArgs e) {
   statusBarPanel1.Text = "Current record: " + (e.NewIndex + 1).ToString();
   statusBarPanel2.Text = "Previously focused record: " + (e.OldIndex + 1).ToString();
   statusBarPanel3.Text = "Record count: " + vGridControl1.RecordCount.ToString();
}
vb
Imports DevExpress.XtraVerticalGrid.Events

Private Sub VGridControl1_FocusedRecordChanged(ByVal sender As Object, _
ByVal e As IndexChangedEventArgs) Handles VGridControl1.FocusedRecordChanged
   StatusBarPanel1.Text = "Current record: " + (e.NewIndex + 1).ToString()
   StatusBarPanel2.Text = "Previously focused record: " + (e.OldIndex + 1).ToString()
   StatusBarPanel3.Text = "Record count: " + VGridControl1.RecordCount.ToString()
End Sub

See Also

VGridControlBase Class

VGridControlBase Members

DevExpress.XtraVerticalGrid Namespace