Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

VGridControlBase.FocusedRecordChanged Event

Fires in response to record focus changing.

Namespace: DevExpress.XtraVerticalGrid

Assembly: DevExpress.XtraVerticalGrid.v24.2.dll

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

#Declaration

public event IndexChangedEventHandler FocusedRecordChanged

#Event Data

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.

#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:

CurrentRecordChanged - event

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();
}
See Also