Getting the Focused Row, Column and Cell in Developer Express XtraGrid

  May 18, 2007

When testing applications that use Developer Express XtraGrid controls,
you may need to know which row, column and cell are currently focused. The
XtraGrid control has special internal properties that let you easily
determine the currently selected element. These properties are listed in the
table below:

Property Description
GridObj.FocusedView Specifies the currently focused grid view. You can use this property, for example, to determine the focused view in the
grid that displays data of multiple nested tables. If the grid displays data
of one table only, this property is always equal to GridObj.MainView.
ViewObj.FocusedRowHandle Specifies the index (zero-based) of the row (card) that is currently selected in the given view.
ViewObj.FocusedColumn Specifies the column (card field) that is currently selected in the given view.

Note that in order for TestComplete to have access to these properties, the
.NET Open Applications plug-in must be installed and enabled.
Below is sample code that demonstrates how you can use these properties to
get the text of the focused cell. The example works with the GridTutorials
demo application that comes with the Developer Express XtraGrid Suite.