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 column’s Options.Editing property specifies whether a user can edit its cells (provided that any cell can be edited, see OptionsData.Editing)
the column’s Options.Focusing enables/disables focusing its cells
the control’s OptionsData.Editing enables/disables editing all columns within this TreeList control
the control’s OptionsSelection.CellSelect determines whether individual columns can be selected within a node
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:
There are two important things that are necessary to remember when using this method:
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.
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).