Get Data Rows and Cell Values
- 2 minutes to read
You can use a data control’s methods to access data records and cell values by the data control’s visual elements: grid rows/tree list nodes and columns.
Get the Data Source’s Records by Grid Rows/Tree List Nodes
You can get underlying data records by grid rows and tree list nodes. Use the following methods to get an object that contains data for a specific grid row/tree list node:
the grid view’s GetRow(Int32) method — returns an Object in the bound data source that contains data for the specified grid row. To specify the grid row in the method’s parameter, use the row’s handle. You can also use the GetFocusedRow() method to get the data row for the focused grid row.
the tree list’s GetRow(Int32) method — returns an Object in the bound data source that contains data for the specified node. To specify the node in the method’s parameter, use the node’s Id property value. You can also use the GetFocusedRow() method to get the data row the focused node.
the vertical grid’s GetRecordObject(Int32) method — returns an Object in the bound data source that contains data for the specified vertical grid record. To specify the vertical grid record in the method’s parameter, use its index.
If the control is bound to a DataTable or DataView, you can use the following methods:
the grid view’s GetDataRow(Int32) — returns a DataRow in the bound DataTable that contains data for the specified grid row. You can also use the GetFocusedDataRow() method to get the DataRow for the focused grid row.
the tree list’s GetDataRow(Int32) — returns a DataRow in the bound DataTable that contains data for the specified node. You can also use the GetFocusedDataRow() method to get the DataRow for the focused node.
Cheat Sheets and Best Practices
DevExpress WinForms UI controls share the same data editing and validation techniques. Read the following quick-reference guides for detailed information on CRUD API used throughout data-aware controls (Data Grid, Tree List, Vertical Grid, Gantt Control, etc.):