Getting Cell Values in Developer Express XtraGrid
When testing an application with the Developer Express XtraGrid control, you often need to get values held in grid cells. This article explains how you can do this and provides sample functions that you can use in your test scripts for this purpose.
Note: In order for TestComplete to be able to access grid cell values, it should have access to internal methods, properties and objects of the XtraGrid control. To enable testComplete to access them, you need to install and enable the .NET Open Application Support plug-in.
To get the value stored in a particular grid cell, you can use the following methos of the grids view in which the desired cell resides:
view.GetRowCellValue (RowIndex, ColumnObj)
The RowIndex parameter of this method is the zero-based index of the grid row (card) containing the desired cell. The ColumnObj parameter specifies the scripting object corresponding to the grid column that contains the cell. The method returns the .NET object corresponding to the cell value. Some simple values, for example,
Boolean and others, are OLE-compatible and thus can be used in scripts directly. To get OLE-compatible values of
DateTime and enumeration values, you should use the
OleValue property added to these objects by TestComplete. To work with complex object values, use their internal properties and methods.
The XtraGrid control can display values using a special formatting applied. For example, it can be configured to use regional options to display different kinds of values, for example: Tuesday, March 19, 2007 instead of 3/19/2007 (for date values), $1234.00 instead of 1234 (for currency values), and so on. In this case you will more likely want to get the actual text displayed in grid cells rather than cell values. The following method of the grids view lets you obtain the cell text:
view.GetRowCellText (RowIndex, ColumnObj)
Below is an example that demonstrates how you can the mentioned methods to get the XtraGrid cell values and display text. The example works with the GridTutorials sample application that comes with the Developer Express XtraGrid Suite. The script contains the following routines: