windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridcontrolbase-9a78d720.md
Fires in response to record focus changing.
Namespace : DevExpress.XtraVerticalGrid
Assembly : DevExpress.XtraVerticalGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid
public event IndexChangedEventHandler FocusedRecordChanged
Public Event FocusedRecordChanged As IndexChangedEventHandler
The FocusedRecordChanged event's data class is IndexChangedEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| NewIndex | Gets the index of the currently focused element. |
| OldIndex | Gets the index of the previously focused element. |
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:
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:
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();
}
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