Skip to main content
A newer version of this page is available. .

Obtaining And Setting Cell Values

  • 2 minutes to read

This topic describes how you can get and set values for TreeList control cells.

Every cell is identified by its node and column. For data-ware TreeList columns, refer to the fields of the connected dataset.

At runtime, a user can easily navigate through nodes and edit cell values. When moving from one node to another within a data-aware TreeList control, changed data is posted to the database. You can prevent a user from editing cells in a number of ways:

The methods of getting and setting TreeList cell values differ depending on the TreeList control type that you are working with: data-ware or unbound TreeList controls.

Unbound TreeList controls

The TcxTreeList control stores data using an internal ExpressDataController object. Use the Values array property of the Node object to get a particular cell value:

MyEditText.Text := MyNode.Values[MyColumn.ItemIndex];

There are two important things that are necessary to remember when using this method:

  1. You have to use the column’s ItemIndex property to access a particular cell. This property is not changed when modifying the column order; while the column’s Index property may be changed.

  2. In the previous versions of the ExpressQuantumTreeList, data was stored in string arrays. Now you may change the data type stored in a column by using the DataBinding.Field.DataType property.

You can set data for nodes in a single call by using the Node.AssignValues method:

MyNode.AssignValues(['Corporate Headquarters', 1000000, 'Monterey',
'(408) 555-1234', '(408) 555-1234']);

Data-aware TreeList controls

For a data-aware TreeList control, you can use the same method to obtain a cell value as for an unbound TreeList control. If you set a cell value via the Values property, the ExpressDataController caches it, but does not update the connected dataset. You can only change data via VCL Dataset (TField) methods or via a DataController object for the focused node (the current record).

cxDBTreeList1.DataController.Edit;
cxDBTreeList1.FocusedNode.Values[col1.ItemIndex] := 'New Value';
cxDBTreeList1.DataController.Post;
See Also