Sie sind auf Seite 1von 172

Unit dxtree

Controls TCustomdxTreeView TdxTreeView

Page 1 of 172

TCustomdxTreeView
Hierarchy Properties Methods Events

Unit dxtree Description TCustomdxTreeView is an abstract base type for tree-view components such as the TdxTreeView and TdxDBTreeView. Use TCustomdxTreeView as a base class when defining components that present information in a hierarchical structure with nodes that can expand or collapse. Drag & drop operations and new methods and features are implemented in the TCustomdxTreeView. IMPORTANT: Do not create instances of the TCustomdxTreeView. To add a tree view control with extended features (such as drag & drop, automatic node expansion during drag & drop operations, custom draw, etc.) use TdxTreeView instead. Use the TdxDBTreeView control to bind the TreeView with database information.

Page 2 of 172

TdxTreeView
Hierarchy Properties

Unit dxtree Description TdxTreeView is a tree-view component with full drag & drop and custom draw support. To bind your DB with tree view control use TdxDBTreeView

Page 3 of 172

A Self-Referenced Structure
To create a self-reference data structure you have to create a UNIQUE field - KEY(ID) field and a field that will be referenced to the KEY(ID) field - PARENT field. The KEY(ID) and PARENT fields must be of the same type.

Page 4 of 172

Smart Record Loading


If your DataSet has more than 1,000 records, you should use the Smart Record load feature. To apply the smart load, follow these steps: 1. Index (or order) the dataset by the PARENT field. 2. Set trSmartRecordLoad in Options. 3. Set the RootValue property to the PARENT value of your 'root' records. If you want to start with a particular record and not display all records in the DBTreeView , you should assign to the RootValue the value of the PARENT field of this particular record and set trCanDBNavigate to False. 4. Write the OnCreateNewKeyValue event handler. When the dxDBTreeView does not load all records, the Maximum KEY field value is incorrect. You have to get the maximum KEY value to the variable on form creation and use it when the user creates new tree nodes. Otherwise on creating a new tree node you may get a key violation error. Smart record loading works in the following manner: On activation of a dataset, the dxDBTreeView loads records which have a PARENT value equal to RootValue (Locate the first record whose parent Value equals RootValue and then fetch and load the records when the values of the PARENT field are equal. That is why your dataset has to be sorted by the PARENT field). Then dxDBTreeView loads records if necessary - on expand nodes and when the dxDBTreeView has to retrieve the full structure of the loaded tree node.

Page 5 of 172

Unit dxdbtree
Controls TdxDBTreeView Objects TdxDBTreeNodes TdxDBTreeNode

Page 6 of 172

TdxDBTreeView
Hierarchy Properties Methods Events

TdxDBTreeView object is a TreeView control that can display and edit a dataset with hierarchical structures (a self-reference dataset). Unit dxdbtree Description TDBTreeView is a window that displays a hierarchical list of items related to a dataset. You can directly manipulate TreeView nodes, using drag & drop and all changes will be reflected in the dataset. On changing the Value of a field related to the DBTreeView, both the label and parent property of the items are changed as well. You can link the TreeView to a database by specifying the data source component (TDataSource) which identifies the dataset as the value of the DBTreeView DataSource property. Set the KeyField property to a field in the dataset to be used as the key value of the items. Set the ParentField property to the field in the dataset you want to use as a parent of items. Set the ListField property to the field in the dataset you want to see as individual labels of items.

Page 7 of 172

TdxDBTreeNodes
Hierarchy Properties Methods

Unit dxdbtree Description The TdxDBTreeNodes object maintains a list of items (TdxDBTreeNode objects). The Items property of the data-aware tree-view control ( theTdxDBTreeView component) which is of TdxDBTreeNodes type maintains the items in the data-aware tree-view. Note: Items are created automatically.

Page 8 of 172

TdxDBTreeNode
Hierarchy Properties Methods

The TdxDBTreeNode object is an individual item of the TdxDBTreeView control. The dxDBTreeNode is related to a DB record. Unit dxdbtree Description The dxDBTreeNode is inherited from TTreeNode. TdxDBTreeNode contains the KeyFieldValue and the ParentFieldValue defined by the KeyField Value and ParentField records of a related DataSet.

Page 9 of 172

Unit dxdbtrel
Controls TCustomdxVTreeViewEdit TCustomdxTreeViewEdit TdxTreeViewEdit TdxDBTreeViewEdit TCustomdxLookupTreeView TdxLookupTreeView TdxDBLookupTreeView

Page 10 of 172

TCustomdxVTreeViewEdit
Hierarchy Properties Methods Events

Unit dxdbtrel Description TCustomdxVTreeViewEdit is an abstract base type for tree-view edit components such as TdxDBTreeViewEdit and TdxDBLookUpTreeView. Use TCustomdxVTreeViewEdit as a base class when defining a control that combines an edit box with a treeview. Do not create instances of the TCustomdxVTreeViewEdit. To add a tree-view edit control, use TdxTreeViewEdit(TdxDBTreeViewEdit) or TdxLookUpTreeView (TdxDBLookUpTreeView).

Page 11 of 172

TCustomdxTreeViewEdit
Hierarchy Properties Methods

Unit dxdbtrel Description TCustomdxTreeViewEdit is an abstract base type for tree-view edit components such as TdxTreeViewEdit and TdxDBTreeViewEdit. Use TCustomdxTreeViewEdit as a base class when defining controls that combines an edit box with a treeview. Do not create instances of the TCustomdxTreeViewEdit. To add a tree-view edit control, use the TdxTreeViewEdit or TdxDBTreeViewEdit.

Page 12 of 172

TdxTreeViewEdit
Hierarchy Properties

Unit dxdbtrel Description TTreeViewEdit component is a control that combines an edit box with a treeview. Users can select an item from the treeview.

Page 13 of 172

TdxDBTreeViewEdit
Hierarchy Properties

Unit dxdbtrel Description The TDBTreeViewEdit component is a data-aware control that combines an edit box with a treeview. Users can edit a field by selecting an item from the drop-down tree-view.

Page 14 of 172

TCustomdxLookupTreeView
Hierarchy Properties Events

Unit dxdbtrel Description TCustomdxLookupTreeView is an abstract base type for the tree-view lookup components such as TdxDBLookupTreeView and TdxLookupTreeView. Use TCustomLookUpTreeView as a base class when defining a control that combines an edit box with a data-aware tree-view for the lookup purpose. Do not create instances of TCustomdxLookupTreeView. To add a data-aware tree-view lookup control, use the TdxDBLookupTreeView or TdxLookupTreeView.

Page 15 of 172

TdxDBLookupTreeView
Hierarchy Properties

TdxDBLookupTreeView component is a data-aware control that combines an edit box with a data-aware tree-view. Unit dxdbtrel Description Use TdxDBLookupTreeView to provide users with a convenient data-aware drop-down tree-view for editing fields that obtain data from other datasets.

Page 16 of 172

Unit dxtrprds
Components TdxDBTreePrintData

Page 17 of 172

TdxDBTreePrintData
Hierarchy Properties

The TdxDBTreePrintData component is a dataset allowing easy printing of reports using self-referenced datasets. Unit dxtrprds Description Use TdxDBTreePrintData to create a report using self-referenced datasets. TdxDBTreePrintData is directly inherited from the TdxMemData. It retrieves the Data from a self-referenced DataSet (linked with the DataSource property) and creates the records in memory, which are sorted in specific order. In addition it creates the following fields: Field Name dx$haschildren Determines whether the record has children. If the 'dx$haschildren' field is True, then the record has children. If the 'dx$haschildren' field is False, then the record does not include children. The level of a record. The first level (level of the 'root' records) is 0. The number of a record. The first number is 1. Description

dx$Level dx$recno

Page 18 of 172

ExpressDBTreeView Frequently Asked Questions


Question 1: Why once I've assigned the ImageField & Images property, each time I move the cursor to any node, the image is replaced with the first image in the image list? Answer: This behavior occurs because the SelectedIndex property of the DBTreeView is 0. If you want the selected index to be the same as the image index, then you have to write the following code on the onChange event handler of the DBTreeView: // Delphi procedure TForm1.DBTreeView1Change(Sender: TObject; Node: TTreeNode); begin Node.SelectedIndex := Node.ImageIndex; end; // C++ Builder void __fastcall TForm1::DBTreeView1Change(TObject *Sender, TTreeNode *Node) { Node->SelectedIndex = Node->ImageIndex; } Question 2: I'm trying to use your DBTreeView component in a Delphi 3 application I am writing. It works fine until I try to enable the SmartRecordLoad option. When I enable it and try to open my table, I receive an "Invalid Variant Type Conversion" error. Answer: You have not assigned the Root Value. DBTreeView tries to load the root records. It uses the locate method YourDataSet.Locate ('YOURKEYFIELD', ROOTVALUE, []); You have to set the RootValue to the key field 'root' records value. The values of the key field 'root' records has to be equal. Question 3: I try to use smart record loading. I indexed my Table and set trSmartRecordLoad to True. When I start my application the DBTreeView doesn't display any nodes. The nodes are displayed only when I press 'Next' button in the DBNavigator. Is this a feature of the smart record loading? Answer: No, You forgot to assign the RootValue property. Set the PARENT value of your 'root' records to this property. Smart record loading works in the following way: On activation of a dataset, it loads records which have the PARENT value equal to RootValue (Locate the first record that the parent Value equals to RootValue and then fetch and load the records while the value of the PARENT field doesn't change. That is why your dataset has to be sorted by the PARENT field). Then DBTreeView loads records when it is necessary on node expansion and when the DBTreeView has to retrieve the full structure of the loaded tree node. In your particular case DBTreeView does the following: 1. Recognizes that you set smart record loading. 2. Checks RootValue and decides that the PARENT value of your 'root' records is NULL. 3. Tries to locate the record with the PARENT value NULL. When there is no such record, DBTreeView does not load any records. 4. When you press the 'Next' button in DBNavigator, DBTreeView checks the trCanDBNavigate and as soon as it is True (by definition it is True) loads the current record (to set it as a selected tree node) and also loads all its parent records recursively. Question 4: We want to use a different field for a Node's text, according to the node level, how can we do this ?
Page 19 of 172

Answer: 1. You have to set ReadOnly to True to disable text editing in DBTreeView. 2. Write code on the OnDisplayItemText event handler to assign your Text a particular TreeNode: // Delphi procedure TForm1.DBTreeViewSetDisplayItemText(Sender: TObject; var DisplayText: string); Var tr : TTreeNode; begin // Get TreeNode tr := DBTreeView.DBTreeNodes.GetTreeNode(TreeQueryID.Value); if tr <> Nil then begin if tr.Level mod 2 = 1 then DisplayText := Fiedl1.Text else DisplayText := ' Fiedl2.Text; end; end; // C++ Builder void __fastcall TForm1::DBTreeViewSetDisplayItemText(TObject *Sender, AnsiString &DisplayText) { // Get TreeNode TTreeNode * tr = DBTreeView->DBTreeNodes->GetTreeNode(TreeQueryID->Value); if(tr != NULL){ if((tr->Level && 1) == 1) DisplayText = Fiedl1->Text; else DisplayText = Fiedl2->Text; } } 3. Add a DBEdit to a Form, bind it with your DataSet 4. Write code on the OnChange event handler to change the DataField of the DBEdit to the required FieldName. // Delphi procedure TForm1.DBTreeViewChange(Sender: TObject; Node: TTreeNode); begin if(DBTreeView.Selected <> Nil) then begin if (DBTreeView.Selected.Level mod 2 = 1) then DBEdit.DataField := 'field1' else DBEdit.DataField := 'field2'; end; end; // C++ Builder void __fastcall TForm1::DBTreeViewChange(TObject *Sender, TTreeNode *Node) { if(DBTreeView->Selected != NULL){ if((DBTreeView->Selected->Level && 1) == 1) DBEdit->DataField = "field1"; else DBEdit->DataField = "field2"; } } Question 5: We would like to use specific fields for the state and image index values, depending on the level.
Page 20 of 172

Answer: You have to write code on the AddNewItem event handler to change the ImageIndex property of a Tree Node. // Delphi procedure TForm1.DBTreeViewAddNewItem(Sender: TObject; var DBTreeNode: TdxDBTreeNode); begin if(DBTreeNode <> Nil) then begin DBTreeNode.ImageIndex := DBTreeNode.Level; DBTreeNode.StateIndex := DBTreeNode.Level; end; end; // C++ Builder void __fastcall TForm1::DBTreeViewAddNewItem(TObject *Sender, TdxDBTreeNode *&DBTreeNode) { if(DBTreeNode != NULL){ DBTreeNode->ImageIndex = DBTreeNode->Level; DBTreeNode->StateIndex = DBTreeNode->Level; } } Question 6: I am trying to insert a child in my tree. My table structure is below, it is recursive in nature. I am using the dbTreeView component. Table structure --------------------ID, auto Parent, integer Name, integer lookup Lookup for Name --------------------------ID, auto Name, String Category, Integer Obsolete, logical (true,false) What method do I use to insert the child since I really need to send the Name as an integer not a string? The addChild method takes a string. I need to set an integer value. Answer: Solutions are the following: The First Option: 1. Create a lookup field in the dataset The Second Option: 1. Set DBTreeView ReadOnly to True. 2. Create a one-to-many relationship between your DataSets. DataSet1 is the second table (lookup table), DataSet2 is the first table (the self-referenced table) DataSet1 ->> DataSet2, BUT DataSet2 (self-reference) is the master DataSet. 3. Write code on OnDisplayItemText event handler to assign the appropriate Text // Delphi procedure TForm1.DBTreeViewSetDisplayItemText(Sender: TObject; var DisplayText: string); begin DisplayText := DataSet1.FindField('name').AsString end;
Page 21 of 172

// C++ Builder void __fastcall TForm1::DBTreeViewSetDisplayItemText(TObject *Sender, AnsiString &DisplayText) { DisplayText = DataSet1->FindField("name")->Text; } Question 7: I use your DBTreeView with the SmartRecordLoad option. When I delete the root record or a record that has > 100 children, the operation takes a great amount of time. Can you decrease the time of such operation? (I use InterBase). Answer: No, DBTreeView can not decrease the time of delete operations when using SmartRecordLoad, but you can do it manually. When you delete the tree node (or record, it does not matter), the DBTreeView checks whether the SmartRecordLoad is active. If the SmartRecordLoad is set, DBTreeView first loads all 'child' records of the deleted record recursively and then deletes them. It works fast with ISAM databases, and you are right that it takes a lot of time if you use C/S architecture. But if you use a C/S architecture you can easily decrease this time dramatically. Instead of using the standard DBTreeView delete operation you have to carry out such operations in the following manner: 1. Create a trigger on Delete. For example (for Interbase): REFTABLE.ID <--->> REFTABLE.PARENT Create Trigger REFTABLE$DELETE For REFTABLE After Delete As Begin Delete From REFTABLE Where PARENT = OLD.ID And ID <> OLD.ID; End Now when deleting a record all children will be deleted automatically. 2. Set the trCanDBDelete to False and obtain the KeyDown event manually: // Delphi procedure TForm1.DBTreeViewKey1Down(Sender: TObject; var Key: Word; Shift: TShiftState); var Query : TQuery; begin // Is it delete key and has the user selected a tree node if(Key = VK_DELETE) And (DBTreeView1.Selected <> Nil) then begin // Create a temporary query Query := TQuery.Create(self); // Set the DataBaseName Query.DataBaseName := 'MyDataBase'; // Assign the SQL property Query.SQL.Add('Delete From REFTABLE Where ID = ' + MYDBTreeDataSet.FindField('id').AsString); // Delete the record and our trigger has to delete its children recursively Query.ExecSQL; // Free the temporary query Query.Free; // Refresh the DataSet MYDBTreeDataSet.Close; MYDBTreeDataSet.Open; end; end;
Page 22 of 172

// C++ Builder //----------------------------------------------------------------void __fastcall TForm1::DBTreeViewKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { // Is it delete key and has the user selected a tree node if((Key == VK_DELETE) && (DBTreeView1->Selected != NULL)){ // Create a temporary query TQuery * Query = new TQuery(this); // Set the DatabaseName Query->DataBaseName = "MyDataBase"; // Assign the SQL property Query->SQL->Add("Delete From REFTABLE Where ID = " + MYDBTreeDataSet->FindField("id")->Text); // Delete the record and our trigger has to delete its children recursively Query->ExecSQL(); // Free the temporary query Query->Free(); // Refresh our DataSet MYDBTreeDataSet->Close(); MYDBTreeDataSet->Open(); } } Question 8: The following code does not work when automatic Drag-Drop is active, but does work when it is inactive: // Delphi procedure TForm1.DBTreeViewMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if ssShift in Shift then begin {do something} end; end; Answer: This is not a problem created by ExpressDBTreeView. Try to perform this operation using any other TWinControl in Delphi or CPB; for instance a ListBox control. The result will be the same. Instead of using "if ssShift in Shift then begin" condition you have to write the following code: "if GetKeyState(VK_SHIFT) < 0 then begin". // Delphi procedure TForm1.DBTreeViewMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if GetKeyState(VK_SHIFT) < 0 then begin {do something} end; end;

Page 23 of 172

TdxDBTreeView Events
TdxDBTreeView

OnAddNewItem OnCreateNewKeyValue OnSetDisplayItemText

Page 24 of 172

TdxDBTreeNode Methods
TdxDBTreeNode

LoadChildren

Page 25 of 172

TdxDBTreeNodes Methods
TdxDBTreeNodes

Count GetKeyFieldValue GetParentValue GetDBTreeNode GetTreeNode

Page 26 of 172

TdxDBTreeView Methods
TdxDBTreeView

GetImageIndexField GetKeyField GetListField GetParentField GetStateIndexField GotoKeyFieldValue IsCustomDraw RefreshItems

Page 27 of 172

TdxDBTreeNode Properties
TdxDBTreeNode

BkColor Color FontStyle FontName IsCustomDraw ChildLoaded KeyFieldValue ParentFieldValue

Page 28 of 172

TdxDBTreeNodes Properties
TdxDBTreeNodes

Items MaxKeyFieldValue

Page 29 of 172

TdxDBTreeView Properties
TdxDBTreeView

DBSelected DBTreeNodes DataSource DisplayField ImageIndexField KeyField ListField ParentField RootValue SeparatedSt StateIndexField Options Derived from TCustomdxTreeView DeletingConfirmationMessage Options SelectedIndex

Page 30 of 172

TdxDBTreeNode.BkColor
TdxDBTreeNodes See Also Example

Specifies the background color of tree node text. property BkColor : TColor; Description Set BkColor to specify the background color of tree node text. Note: IsCustomDraw property has to be set to True.

Page 31 of 172

TdxDBTreeNode.ChildLoaded
TdxDBTreeNodes See Also Example

Determines whether children of a dxDBTreeNode are loaded. property ChildLoaded : Boolean; Description Read-Only. Use ChildLoaded to determine whether children of a DBTreeNode are loaded. If you do not use the smart record loading features, ChildLoaded is always True.

Page 32 of 172

TdxDBTreeNode.Color
TdxDBTreeNodes See Also Example

Specifies the color of tree node text. property Color : TColor; Description Set Color to specify the color of the tree node text Note: IsCustomDraw property has to be set to True.

Page 33 of 172

TdxDBTreeNode.FontName
TdxDBTreeNodes See Also Example

Specifies the font name of tree node text. property FontName : TFontName; Description Set FontName to specify the font name of tree node text. Note: IsCustomDraw property has to be set to True.

Page 34 of 172

TdxDBTreeNode.FontStyle
TdxDBTreeNodes See Also Example

Specifies the font style of tree node text. property FontStyle : TFontStyles; Description Set FontStyle to specify the font style of tree node text. Note: IsCustomDraw property has to be set to True.

Page 35 of 172

TdxDBTreeNode.IsCustomDraw
TdxDBTreeNodes See Also Example

Specifies whether a particular tree node draws font and color properties of the TdxDBTreeView by default or by using the BkColor, Color, FontStyle and FontName properties of this TdxDBTreeNode. property IsCustomDraw : Boolean; Description Set IsCustomDraw to specify whether a particular tree node draws the font and color properties of the TdxDBTreeView by default or whether it uses BkColor, Color, FontStyle and FontName properties of this TdxDBTreeNode. By default IsCustomDraw is set to False.

Page 36 of 172

TdxDBTreeNode.KeyFieldValue
TdxDBTreeNodes See Also

Determines the Value of KEY field associated with a dxDBTreeNode. property KeyFieldValue : Variant; Description Run-time and Read-Only. Use KeyFieldValue to determine the Value of a KEY field associated with a dxDBTreeNode.

Page 37 of 172

TdxDBTreeNode.LoadChildren
TdxDBTreeNodes See Also

Loads child tree nodes. procedure LoadChildren(Recurse: Boolean); Description Call LoadChildren to load tree node children when using the smart record loading feature. Set the Recurse parameter to True to load all tree node records.

Page 38 of 172

TdxDBTreeNode.ParentFieldValue
TdxDBTreeNodes See Also

Determines the Value of a PARENT field associated with a DBTreeNode. property ParentFieldValue: Variant; Description Run-time and Read-Only. Use ParentFieldValue to determine the Value of a ParentFieldValue field associated with a dxDBTreeNode.

Page 39 of 172

TdxDBTreeNodes.Count
TdxDBTreeNodes

Determines the number of DBTreeNode items in an object. function Count : Integer; Description Call Count to determine the number of DBTreeNode items in an object.

Page 40 of 172

TdxDBTreeNodes.GetDBTreeNode
TdxDBTreeNodes

Returns DBTreeNode items by its KeyValue. function GetDBTreeNode(Value : Variant) : TDBTreeNode; Description Call GetDBTreeNode to return DBTreeNode items by its KeyValue.

Page 41 of 172

TdxDBTreeNodes.GetKeyFieldValue
TdxDBTreeNodes See Also

Returns the Value of the KeyField field associated with a dxDBTreeNode. function GetKeyFieldValue(Value : TTreeNode) : Variant; Description Call GetKeyFieldValue to return the KeyField field Value associated with a TreeNode parameter Value.

Page 42 of 172

TdxDBTreeNodes.GetParentValue
TdxDBTreeNodes See Also

Returns the Value of the ParentField field associated with a dxDBTreeNode. function GetParentValue(Value : TTreeNode) : Variant; Description Call GetParentValue to return the Value of the ParentField field associated with a TreeNode parameter Value.

Page 43 of 172

TdxDBTreeNodes.GetTreeNode
TdxDBTreeNodes

Returns the TreeNode items by its KeyValue. function GetTreeNode(Value : Variant) : TTreeNode; Description Call GetTreeNode to return TreeNode items by its KeyValue.

Page 44 of 172

TdxDBTreeNodes.Items
TdxDBTreeNodes See Also

An index of the DBdxTreeNodes in the TdxDBTreeNodes. property Items[Index: Integer]: TDBTreeNode; Description The Items property contains individual items that appear in the dbtree view control. Individual nodes in the TdxDBTreeView are the TdxDBTreeNode objects. These items can be accessed by means of the Items property along with the item's index into the dbtree view. For example, to access the first db item in a DBTreeView, you could use the following code: MyDBTreeNode := DBTreeView1.DBNodes[0];

Page 45 of 172

TdxDBTreeNodes.MaxKeyFieldValue
TdxDBTreeNodes See Also Example

Determines the greatest value of the dxDBTreeNode Key value. property MaxKeyFieldValue : Variant; Description Use MaxKeyFieldValue to determine the greatest value of the DBTreeNode Key value. Note: When using smart record loading, this value will be incorrect.

Page 46 of 172

TdxDBTreeView.DataSource
TdxDBTreeView See Also

Identifies a link to the dataset where a data-aware tree view locates its data. property DataSource: TDataSource; Description Set DataSource to the TDataSource object that links to a dataset where the data-aware tree-view should fetch its data. The linked dataset must have a self-reference structure.

Page 47 of 172

TdxDBTreeView.DBSelected
TdxDBTreeView See Also

Returns the DB item in a selected DBtree view. property DBSelected : TdxDBTreeNode; Description Run-time and read only. Use DBSelected to retrieve the selected DB item in a data-aware tree-view. This is included only for compatibility with RSD DBTreeView. The TdxDBTreeNode is inherited from the TTreeNode: MyTreeView.DBSelected = TdxDBTreeNode(MyTreeView.Selected);

Page 48 of 172

TdxDBTreeView.DBTreeNodes
TdxDBTreeView

DBTreeNodes is an indexed array of all TDBTreeNodes in a data-aware tree-view. property DBTreeNodes : TdxDBTreeNodes; Description Use the DBTreeNodes to gain direct access to a particular dxDBTreeNode in a data-aware tree-view. Specify which DB item to access by means of Index, where an Index of 0 specifies the first item, an Index of 1 specifies the second item, etc. Each item is a TdxDBTreeNode object. The items are created automatically. This is included only for compatibility with RSD DBTreeView. The TdxDBTreeNode is inherited from the TTreeNode.

Page 49 of 172

TdxDBTreeView.DisplayField
TdxDBTreeView See Also

Identifies the field (or fields) from which a data-aware tree-view displays data. property DisplayField : String; Description Set the DisplayField property to a field name or multiple field names (separated by semicolons) whose values you would like to display for a TreeNodes Text. You have to use this property if you wish to display more than one field or a field different from the ListField.

Page 50 of 172

TdxDBTreeView.GetImageIndexField
TdxDBTreeView See Also

Returns the ImageIndexField. function GetImageIndexField : TField; Description Call GetImageIndexField to return the ImageIndexField if a linked DataSet is Active and the ImageIndexField property has been assigned, otherwise returns Nil.

Page 51 of 172

TdxDBTreeView.GetKeyField
TdxDBTreeView See Also

Returns the KeyField. function GetKeyField : TField; Description Call GetKeyField to return the KeyField if a linked DataSet is Active and the KeyField property has been assigned, otherwise returns Nil.

Page 52 of 172

TdxDBTreeView.GetListField
TdxDBTreeView See Also

Returns the ListField. function GetListField : TField; Description Call GetListField to return the ListField if a linked DataSet is Active and the ListField property has been assigned, otherwise returns Nil.

Page 53 of 172

TdxDBTreeView.GetParentField
TdxDBTreeView See Also

Returns the ParentField. function GetParentField: TField; Description Call GetParentField to return the ParentField if a linked DataSet is Active and the ParentField property has been assigned, otherwise returns Nil.

Page 54 of 172

TdxDBTreeView.GetStateIndexField
TdxDBTreeView See Also

Returns the StateIndexField function GetStateIndexField : TField; Description Call GetStateIndexField to return the StateIndexField if a linked DataSet is Active and the StateIndexField property has been assigned, otherwise returns Nil.

Page 55 of 172

TdxDBTreeView.GotoKeyFieldValue
TdxDBTreeView See Also

Allows you to move to a particular DBTreeNode Item. procedure GotoKeyFieldValue(Value : Variant); Description Call GotoKeyFieldValue to navigate to a dxDBTreeNode Item whose KeyValue is equal to Value.

Page 56 of 172

TdxDBTreeView.ImageIndexField
TdxDBTreeView See Also

Specifies the field used by a data-aware tree-view control to set the ImageIndex property of a TreeNode. property ImageIndexField: String; Description Set ImageIndexField to specify the field used by a data-aware tree-view control to set the ImageIndex property of the TreeNode. The dataset of the field is specified by the data source component (TDataSource). ImageIndexField must be an integer field.

Page 57 of 172

TdxDBTreeView.IsCustomDraw
TdxDBTreeView See Also

Determines whether custom draw is used. function IsCustomDraw : Boolean; override; Description Call IsCustomDraw to determine whether custom draw is used. It returns True if custom draw is used and False if not. Custom draw is used if you write code within the OnCustomDraw event handler or if at least one IsCustomDraw property of the DBTreeNode object is set to True.

Page 58 of 172

TdxDBTreeView.KeyField
TdxDBTreeView See Also

Identifies the KEY field of a self-reference dataset. property KeyField: string; Description Set the KeyField property to a KEY field in a self-reference dataset. The dataset is specified by a data source component (TDataSource).

Page 59 of 172

TdxDBTreeView.ListField
TdxDBTreeView See Also

Identifies the field which displays item labels for a data-aware tree-view control. property ListField: string; Description Set the ListField property to identify the field which displays the item labels for a data-aware tree-view control. The dataset of the field is specified by a data source component (TDataSource).

Page 60 of 172

TdxDBTreeView.OnAddNewItem
TdxDBTreeView Example

Occurs when dxDBTreeView must add a new item. TAddNewDBTreeNodeEvent= procedure(Sender: TObject; var DBTreeNode: TdxDBTreeNode) of Object; property OnAddNewItem : TAddNewDBTreeNodeEvent; Description Use OnAddNewItem event to perform particular operations when adding new items, for example to assign an ImageIndex, SelectedIndex and StateIndex property of a TreeNode item.

Page 61 of 172

TdxDBTreeView.OnCreateNewKeyValue
TdxDBTreeView See Also Example

Occurs when a data-aware tree-view has already inserted the tree node and tries to insert a new record in the dataset. TCreateNewKeyValue = procedure(Sender: TObject; var NewKeyValue: Variant) of Object; property OnCreateNewKeyValue : TCreateNewKeyValue; Description Write an OnCreateNewKeyValue event handler to assign a new Key Value to the newly inserted tree node. The NewKeyValue is the greatest value in the Key field plus 1 for integer and float fields. This gives a programmer the opportunity to change the NewKeyValue (the key value for new data record). It is especially useful if the key field is not integer and is not float. Note: You must assign this event if you use SmartLoad. If dxDBTreeView does not load all records, it has an incorrect maximum value of the key field.

Page 62 of 172

TdxDBTreeView.OnSetDisplayItemText
TdxDBTreeView See Also Example

Occurs when a data-aware tree-view has to display an item. TSetDisplayItemText = procedure(Sender: TObject; var DisplayText: String) of Object; property OnSetDisplayItemText : TSetDisplayItemText; Description Write an OnSetDisplayItemText event handler to assign tree node Text a specific value. DisplayText is the text to be displayed.

Page 63 of 172

TdxDBTreeView.Options
TdxDBTreeView See Also

Specifies various behavioral properties of the data-aware tree-view. TdxDBTreeViewOption = (trDBCanDelete, trDBConfirmDelete, trCanDBNavigate, trSmartRecordLoad, trSmartRecordCopy, trCheckHasChildren); TdxDBTreeViewOptions = set of TdxDBTreeViewOption; property Options : TdxDBTreeViewOptions; Description Set Options to include the desired properties for the data-aware tree-view. Options is a set drawn from the following values: Value trDBCanDelete trDBConfirmDelete trCanDBNavigate trSmartRecordLoad trSmartRecordCopy trCheckHasChildren Deletes the selected tree node and its structure, when the user presses the Delete key. A message box appears, asking for confirmation, when a user presses the Delete key to delete a node in the DBTreeView. The trDBCanDelete must also be set. On changing the DB cursor in a linked DataSet, the selected tree node is also changed. DBTreeView uses the smart record loading feature. On drag & drop events, copies the associated data in the dataset. By default the Key, Parent and Name fields are the only items copied. Checks whether a tree node includes children. By default this options is inactive and dxDBTreeView does not check whether a node has children when using the smart record load feature. The resultant effect is that the HasChildren property of all nodes equals True (the plus symbol is shown within the tree). To check whether nodes have children (dxDBTreeView tries to find any child records) set this option. If you do not use the smart record load feature, dxDBTreeView ignores this option. Meaning

Page 64 of 172

TdxDBTreeView.ParentField
TdxDBTreeView See Also

Identifies the PARENT field of a self-reference dataset. property ParentField: string; Description Set the ParentField property to the PARENT field of a self-reference dataset. The dataset of the field is specified by a data source component (TDataSource).

Page 65 of 172

TdxDBTreeView.RefreshItems
TdxDBTreeView

Refreshes the items of a data-aware tree-view. procedure RefreshItems; Description Call RefreshItems to refresh the items of a data-aware tree-view. You rarely need to call this procedure directly.

Page 66 of 172

TdxDBTreeView.RootValue
TdxDBTreeView See Also

Determines the PARENT value of your 'root' records. property RootValue : String; Description Set the RootValue property to the PARENT value of your 'root' records. This is a critical property when using smart record loading. When a dataset is activated, DBTreeView loads the records which have a PARENT value equal to RootValue (locate the first record which the parent Value equals to RootValue and then fetch and load the records when the values of their PARENT field are equal. That is why your dataset has to be sorted by the PARENT field).

Page 67 of 172

TdxDBTreeView.SeparatedSt
TdxDBTreeView See Also

Determines the string which is used as a separator between values of different fields in a Tree Nodes Text, once the DisplayField property is assigned. property SeparatedSt : string; Description Set SeparatedSt to determine the string which is used as separators between values of different fields in a Tree Nodes Text, once the DisplayField property is assigned. The default value is ' - '.

Page 68 of 172

TdxDBTreeView.StateIndexField
TdxDBTreeView See Also

Specifies the field which is used by a data-aware tree-view control to set the StateIndex property of a TreeNode. property StateIndexField: String; Description Set StateIndexField to specify the field which is used by a data-aware tree-view control to set the StateIndex property of a TreeNode. The dataset is specified by a data source component (TDataSource). StateIndexField must be an integer field.

Page 69 of 172

TCustomdxLookupTreeView Events
TCustomdxLookupTreeView

OnAddNewItem OnSetDisplayItemText

Page 70 of 172

TCustomdxVTreeViewEdit Events
TCustomdxVTreeView Edit

OnCloseUp OnCustomDraw OnDropDown OnGetSelectedIndex OnGetImageIndex

Page 71 of 172

TCustomdxTreeViewEdit Methods
TCustomdxTreeView Edit

GetTreeNodeByText

Page 72 of 172

TCustomdxVTreeViewEdit Methods
TCustomdxVTreeView Edit

CloseUp DropDown

Page 73 of 172

TCustomdxLookupTreeView Properties
TCustomdxLookupTreeView

In TCustomdxLookupTreeView AssignField DisplayField ImageIndexField ListSource KeyField ListField Options ParentField RootValue StateIndexField Derived from TCustomdxVTreeViewEdit DividedChar TextStyle

Page 74 of 172

TCustomdxTreeViewEdit properties
TCustomdxTreeView Edit

In TCustomdxTreeViewEdit Items Derived from TCustomdxVTreeViewEdit DividedChar TextStyle

Page 75 of 172

TCustomdxVTreeViewEdit Properties
TCustomdxVTreeView Edit

DividedChar TextStyle Selected CanSelectParents DropDownRows DropDownWidth Text TreeViewColor TreeViewCursor TreeViewFont TreeViewHint TreeViewImages TreeViewIndent TreeViewPopupMenu TreeViewReadOnly TreeViewShowButtons TreeViewShowHint TreeViewShowLines TreeViewShowRoot TreeViewSortType TreeViewStateImages

Page 76 of 172

TdxDBLookupTreeView properties
TdxDBLookupTreeView

Field DataField DataSource ReadOnly

Page 77 of 172

TdxDBTreeViewEdit Properties
TdxDBTreeView Edit

Field DataField DataSource ReadOnly

Page 78 of 172

TdxLookupTreeView properties
TdxLookupTreeView

Alignment

Page 79 of 172

TdxTreeViewEdit properties
TdxTreeView Edit

Alignment

Page 80 of 172

TCustomdxLookupTreeView.AssignField
TCustomdxLookupTreeView See Also

Identifies the field in a ListSource dataset that matches the value of a DataField. property AssignField: String; Description Use AssignField to link a ListSource of the lookup TreeView to a DataSource. Though the name of the field specified as the AssingField must not to be the same as the name of the field specified as the DataField, the two fields must have the same values. Generally, the KeyField and AssignField in the lookup TreeView are the same, in which case you can leave the AssignField empty.

Page 81 of 172

TCustomdxLookupTreeView.DisplayField
TCustomdxLookupTreeView See Also

Specifies the DisplayField property of a drop-down data-aware tree view control. property DisplayField: String; Description Use DisplayField to specify the DisplayField property of a drop-down data-aware tree view control.

Page 82 of 172

TCustomdxLookupTreeView.ImageIndexField
TCustomdxLookupTreeView See Also

Specifies the field, which is used by a data-aware tree-view control to set the ImageIndex property of a TreeNode. property ImageIndexField: String; Description Set ImageIndexField to specify the field, which is used by the data-aware tree-view control to set the ImageIndex property of a TreeNode. The dataset is specified by a data source component (TDataSource). ImageIndexField must be an integer field.

Page 83 of 172

TCustomdxLookupTreeView.KeyField
TCustomdxLookupTreeView See Also

Specifies the KeyField of a drop-down tree-view. property KeyField: String; Description Use KeyField to specify the KeyField of a drop-down tree-view. If the AssignField is empty, the lookup tree view uses the KeyField to link the ListSource to the DataSource.

Page 84 of 172

TCustomdxLookupTreeView.ListField
TCustomdxLookupTreeView See Also

Specifies the ListField of a drop-down tree-view. property ListField: String; Description Use ListField to specify the ListField of a drop-down tree-view.

Page 85 of 172

TCustomdxLookupTreeView.ListSource
TCustomdxLookupTreeView See Also

Specifies the DataSource of a drop-down tree-view. property ListSource: TDataSource; Description Use ListSource to specify the DataSource of a drop-down tree-view.

Page 86 of 172

TCustomdxLookupTreeView.OnAddNewItem
TCustomdxLookupTreeView See Also

Occurs when a data-aware drop-down tree-view must add a new item. TAddNewDBTreeNodeEvent= procedure(Sender: TObject; var DBTreeNode: TdxDBTreeNode) of Object; property OnAddNewItem : TAddNewDBTreeNodeEvent; Description Write an OnAddNewItem event handler to perform specific operations when adding a new item to the data-aware drop-down treeview. Use it, for example, to assign the ImageIndex, SelectedIndex and StateIndex property of a tree node item.

Page 87 of 172

TCustomdxLookupTreeView.OnSetDisplayItemText
TCustomdxLookupTreeView See Also

Specifies the OnSetDisplayItemText of a drop-down tree-view. TSetDisplayItemText = procedure(Sender: TObject; var DisplayText: String) of Object; property OnSetDisplayItemText : TSetDisplayItemText; Description Use OnSetDisplayItemText to specify the OnSetDisplayItemText of a drop-down tree-view.

Page 88 of 172

TCustomdxLookupTreeView.Options
TCustomdxLookupTreeView

Specifies the Options of a drop-down tree-view. property Options: TdxDBTreeViewOptions; Description Use Options to specify the Options of a drop-down tree-view.

Page 89 of 172

TCustomdxLookupTreeView.ParentField
TCustomdxLookupTreeView See Also

Specifies the Options of a drop-down tree-view. property ParentField: String; Description Use ParentField to specify the ParentField of a drop-down tree-view.

Page 90 of 172

TCustomdxLookupTreeView.RootValue
TCustomdxLookupTreeView See Also

Specifies the Options of a drop-down tree-view. property RootValue: String; Description Use RootValue to specify the RootValue of a drop-down tree-view.

Page 91 of 172

TCustomdxLookupTreeView.StateIndexField
TCustomdxLookupTreeView See Also

Specifies the field used by a data-aware tree-view control to set the StateIndex property of a tree node. property StateIndexField: String; Description Set StateIndexField to specify the field used by a data-aware tree-view control to set the StateIndex property of a tree node. The dataset is specified by a data source component (TDataSource). StateIndexField must be an integer field.

Page 92 of 172

TCustomdxTreeViewEdit.GetTreeNodeByText
TCustomdxTreeView Edit

Returns the tree node of a drop-down tree-view control by its text. function GetTreeNodeByText(ParentTreeNode : TTreeNode; Text : String; flag : Boolean) : TTreeNode; Description Call GetTreeNodeByText to get the tree node of a drop-down tree-view control by its text. The ParentTreeNode parameter is a tree node from which the searching begins. To search all children of the ParentTreeNode recursively, set the flag parameter to True. To search the entire tree view, use nil as a ParentTreeNode parameter.

Page 93 of 172

TCustomdxTreeViewEdit.Items
TCustomdxTreeView Edit

Items is the items of a drop-down tree-view control. property Items : TTreeNodes; Description The Items array property allows you to access a specific pointer kept in the Items property of a drop-down tree-view control.

Page 94 of 172

TCustomdxVTreeViewEdit.CanSelectParents
TCustomdxVTreeView Edit

Specifies whether a user may choose a tree node with children from the drop-down tree-view. property CanSelectParents : Boolean; Description Use CanSelectParents to specify whether a user may choose a tree node with children from the popup tree-view. If CanSelectParents is True, then the user may choose the tree node, with children. If CanSelectParents is False, then he or she cannot.

Page 95 of 172

TCustomdxVTreeViewEdit.CloseUp
TCustomdxVTreeView Edit See Also

Closes a drop-down tree-view control. procedure CloseUp(Accept: Boolean); virtual; Description Call CloseUp to programmatically close a drop-down tree-view control. The Accept parameter determines whether to modify the field value with the value that corresponds to the selected node in a drop-down tree-view control.

Page 96 of 172

TCustomdxVTreeViewEdit.DividedChar
TCustomdxVTreeView Edit See Also

Specifies the char that separates the Text property. property DividedChar : Char; Description Use DividedChar to specify the char that separates the Text property. For example if the DividedChar is '-', the selected item is 'San Jose' and its parents are 'CA' and 'US', the Text would be the following: 'US-CA-San Jose'.

Page 97 of 172

TCustomdxVTreeViewEdit.DropDown
TCustomdxVTreeView Edit See Also

Opens a drop-down tree-view control so that a user can choose a tree node. procedure DropDown; virtual; Description Call DropDown to programmatically open a drop-down tree-view control. Before a tree-view control is displayed, the OnDropDown event is generated.

Page 98 of 172

TCustomdxVTreeViewEdit.DropDownRows
TCustomdxVTreeView Edit See Also

Specifies the maximum number of tree nodes displayed at one time within the drop-down tree-view. property DropDownRows: Integer; Description Set DropDownRows to specify the maximum number of tree nodes displayed within the drop-down tree-view.

Page 99 of 172

TCustomdxVTreeViewEdit.DropDownWidth
TCustomdxVTreeView Edit See Also

Determines the width of a drop-down treeview property DropDownWidht : Boolean; Description Use DropDownWidth to set the width of the drop-down treeview by default. If the DropDownWidht is 0, then the width of the dropdown treeview will be the same as of the treeview editor. Note: A user can change the DropDownWidth property at run-time by re-sizing the drop-down tree-view window.

Page 100 of 172

TCustomdxVTreeViewEdit.OnCloseUp
TCustomdxVTreeView Edit See Also

Occurs immediately after a drop-down tree-view control is closed. TdxTreeViewCloseUp = procedure (Sender : TObject; Accept : Boolean) of object; property OnCloseUp: TdxTreeViewCloseUp; Description Write an OnCloseUp event handler to respond when a drop-down tree-view control is closed. When the drop-down tree-view control is closed, the Text of a selected tree node (or the value that corresponds to the selected node for lookup controls) is assigned to the field. The drop-down tree-view control can be closed by a user or by calling the CloseUp method.

Page 101 of 172

TCustomdxVTreeViewEdit.OnCustomDraw
TCustomdxVTreeView Edit See Also

Occurs when a drop-down tree-view control paints a particular tree node in using the custom draw services and the Win32 API requests the font and color for this particular tree node. TTreeViewCustomDraw = procedure(Sender : TObject; TreeNode : TTreeNode; Var AFont : TFont; Var AColor, ABkColor : TColor) of object; property OnCustomDraw: TTreeViewCustomDraw; Description Use the OnCustomDraw event handler to implement custom draw services. The OnCustomDraw handler can set the font, color and background color of text for a particular tree node of a drop-down tree-view control.

Page 102 of 172

TCustomdxVTreeViewEdit.OnDropDown
TCustomdxVTreeView Edit See Also

Occurs immediately before a drop-down tree-view control is opened. property OnDropDown: TNotifyEvent; Description Write an OnDropDown event handler to perform specific actions before a drop-down tree-view control is displayed to the user. The drop-down tree-view control can be opened by a user or by calling the DropDown method.

Page 103 of 172

TCustomdxVTreeViewEdit.OnGetImageIndex
TCustomdxVTreeView Edit

Occurs when a tree view looks up the ImageIndex of a node of a drop-down tree view. type TTVExpandedEvent = procedure(Sender: TObject; Node: TTreeNode) of object; property OnGetImageIndex: TTVExpandedEvent; Description Write an OnGetImageIndex event handler to change the image index for a particular node of a drop-down tree view before it is drawn. For example, the bitmap of a node can be changed to indicate a different state for the node.

Page 104 of 172

TCustomdxVTreeViewEdit.OnGetSelectedIndex
TCustomdxVTreeView Edit

Occurs when a drop-down tree view looks up the SelectedIndex of a node of a drop-down tree view. type TTVExpandedEvent = procedure(Sender: TObject; Node: TTreeNode) of object; property OnGetSelectedIndex: TTVExpandedEvent; Description Write an OnGetSelectedIndex event handler to change the selected image index of a node of a drop-down tree view before it is drawn.

Page 105 of 172

TCustomdxVTreeViewEdit.Selected
TCustomdxVTreeView Edit

Determines the selected tree node in a drop-down tree-view control. property Selected : TTreeNode; Description Use Selected to determine the selected tree node in a drop-down tree-view control.

Page 106 of 172

TCustomdxVTreeViewEdit.Text
TCustomdxVTreeView Edit See Also

Contains the text associated with the control. property Text : String; Description Text equals the label of the selected item if the TextStyle is tvtsShort and to the label of the selected item and all labels of its parent items separated by the DividedChar property if the TextStyle is tvtsFull.

Page 107 of 172

TCustomdxVTreeViewEdit.TextStyle
TCustomdxVTreeView Edit See Also

Specifies the method of displaying TCustomAutoTreeViewEdit Text. TTVTextStyle = (tvtsShort, tvtsFull); property TextStyle : TTVTextStyle; Description Use TextStyle to specify the method of displaying TCustomdxVTreeViewEdit Text. The Text equals the label of the selected item if the TextStyle is tvtsShort and to the label of the selected item and all labels of its parent items separated by the DividedChar property if the TextStyle is tvtsFull.

Page 108 of 172

TCustomdxVTreeViewEdit.TreeViewColor
TCustomdxVTreeView Edit See Also

Specifies the color of a drop-down tree-view control. property TreeViewColor : TColor; Description Use TreeViewColor to specify the color of a drop-down tree-view control.

Page 109 of 172

TCustomdxVTreeViewEdit.TreeViewCursor
TCustomdxVTreeView Edit See Also

Specifies the cursor of a drop-down tree-view control. property TreeViewCursor : TCursor; Description Use TreeViewCursor to specify the cursor of a drop-down tree-view control.

Page 110 of 172

TCustomdxVTreeViewEdit.TreeViewFont
TCustomdxVTreeView Edit See Also

Specifies the font of a drop-down tree-view control. property TreeViewFont : TFont; Description Use TreeViewFont to specify the font of a drop-down tree-view control.

Page 111 of 172

TCustomdxVTreeViewEdit.TreeViewHint
TCustomdxVTreeView Edit See Also

Specifies the hint of a drop-down tree-view control. property TreeViewHint : String; Description Use TreeViewHint to specify the hint of a drop-down tree-view control.

Page 112 of 172

TCustomdxVTreeViewEdit.TreeViewImages
TCustomdxVTreeView Edit See Also

Specifies the images of a drop-down tree-view control. property TreeViewImages : TImageList; Description Use TreeViewImages to specify the images of a drop-down tree-view control.

Page 113 of 172

TCustomdxVTreeViewEdit.TreeViewIndent
TCustomdxVTreeView Edit See Also

Specifies the indentation of a drop-down tree-view control. property TreeViewIndent : Integer; Description Use TreeViewIndent to specify the indentation of a drop-down tree-view control.

Page 114 of 172

TCustomdxVTreeViewEdit.TreeViewPopupMenu
TCustomdxVTreeView Edit See Also

TreeViewPopupMenu specifies the popup menu of a drop-down tree-view control. property TreeViewPopupMenu : TPopupMenu; Description Use TreeViewPopupMenu to specify the popup menu of a drop-down tree-view control.

Page 115 of 172

TCustomdxVTreeViewEdit.TreeViewReadOnly
TCustomdxVTreeView Edit See Also

Specifies if ReadOnly determines whether the user can edit the node of a drop-down tree-view control. property TreeViewReadOnly : Boolean; Description Use TreeViewReadOnly to specify if ReadOnly determines whether the user can edit the node of a drop-down tree-view control.

Page 116 of 172

TCustomdxVTreeViewEdit.TreeViewShowButtons
TCustomdxVTreeView Edit See Also

Specifies whether to display plus (+) and minus (-) buttons to the left of each parent item of a drop-down tree-view control. property TreeViewShowButtons: Boolean; Description If TreeViewShowButtons is True, a button will appear to the left of each parent item of a drop-down tree-view control. A user can click the button to expand or collapse the child items as an alternative to double-clicking the parent item.

Page 117 of 172

TCustomdxVTreeViewEdit.TreeViewShowHint
TCustomdxVTreeView Edit See Also

Determines the ShowHint property of a drop-down tree-view control. property TreeViewShowHint: Boolean; Description Use TreeViewImages to determine the ShowHint property of a drop-down tree-view control.

Page 118 of 172

TCustomdxVTreeViewEdit.TreeViewShowLines
TCustomdxVTreeView Edit See Also

Specifies whether lines that link child nodes of a drop-down tree-view control to their corresponding parent nodes are displayed. property TreeViewShowLines: Boolean; Description If TreeViewShowLines is True, the lines linking child nodes of a drop-down tree-view control to their parent nodes are displayed. The nodes at the root of the hierarchy are not automatically linked. To link nodes at the root, the TreeViewShowRoot property must also be set to True.

Page 119 of 172

TCustomdxVTreeViewEdit.TreeViewShowRoot
TCustomdxVTreeView Edit See Also

Specifies whether lines connecting the top-level nodes of a drop-down tree-view control are displayed. property TreeViewShowRoot: Boolean; Description To display the lines in a drop-down tree-view control connecting the top-level nodes to a single root, set the TreeViewShowRoot and TreeViewShowLines properties of the tree view to True.

Page 120 of 172

TCustomdxVTreeViewEdit.TreeViewSortType
TCustomdxVTreeView Edit See Also

Determines the sort type of a drop-down tree-view control. property TreeViewSortType : TSortType; Description Use TreeViewSortType to determine the sort type of a drop-down tree-view control.

Page 121 of 172

TCustomdxVTreeViewEdit.TreeViewStateImages
TCustomdxVTreeView Edit See Also

Determines the state images of a drop-down tree-view control. property property TreeViewStateImages : TImageList; Description Use TreeViewStateImages to determine the state images of a drop-down tree-view control.

Page 122 of 172

TdxDBLookupTreeView.DataField
TdxDBLookupTreeView See Also

Specifies the field from which TdxDBTreeViewEdit displays data. property DataField: string; Description Use DataField to bind TdxDBTreeViewEdit to a field in a dataset. To fully specify a database field, both the dataset and the field within that dataset must be defined. The DataSource property of the edit box control specifies the dataset that contains the DataField.

Page 123 of 172

TdxDBLookupTreeView.DataSource
TdxDBLookupTreeView See Also

Links the TdxDBLookupTreeView to a dataset which contains the field it represents. property DataSource: TDataSource; Description Use DataSource to link TdxDBLookupTreeView to a dataset in which the data is found. To fully specify a database field for the edit control, both the dataset and a field within that dataset must be defined. Use the DataField property to specify a particular field within the dataset.

Page 124 of 172

TdxDBLookupTreeView.Field
TdxDBLookupTreeView See Also

Specifies the TField object for a database field represented by TdxDBLookupTreeView. property Field: TField; Description Read Field to get direct access to the contents and properties of a database. Use Field to change the contents of the database field programmatically.

Page 125 of 172

TdxDBLookupTreeView.ReadOnly
TdxDBLookupTreeView

Determines whether a user can change the value of a field. property ReadOnly: Boolean; Description Set ReadOnly to specify whether TdxDBLookupTreeView is used for display purposes only. If ReadOnly is True, TdxDBLookupTreeView can only be used for display purposes. If ReadOnly is False, the user can use the TdxDBLookupTreeView to edit a field's value.

Page 126 of 172

TdxDBTreeViewEdit.DataField
TdxDBTreeView Edit See Also

Specifies the field from which the TdxDBTreeViewEdit displays its data. property DataField: string; Description Use DataField to bind the TdxDBTreeViewEdit to a field in a dataset. To fully specify a database field, both the dataset and the field within that dataset must be defined. The DataSource property of an edit box control specifies the dataset that contains the DataField.

Page 127 of 172

TdxDBTreeViewEdit.DataSource
TdxDBTreeView Edit See Also

DataSource links the TdxDBTreeViewEdit to a dataset. property DataSource: TDataSource; Description Use DataSource to link the TdxDBTreeViewEdit to a dataset from where data is obtained. To fully specify a database field for an edit control, both the dataset and a field within that dataset must be defined. Use the DataField property to specify a particular field within the dataset.

Page 128 of 172

TdxDBTreeViewEdit.Field
TdxDBTreeView Edit See Also

Specifies the TField object for a database field represented by TdxDBTreeViewEdit. property Field: TField; Description Read Field to get direct access to the contents and properties of a database. Use Field to change the contents of a database field programmatically.

Page 129 of 172

TdxDBTreeViewEdit.ReadOnly
TdxDBTreeView Edit See Also

Determines if a user can change the value of a field. property ReadOnly: Boolean; Description Set ReadOnly to specify whether TdxDBTreeViewEdit should be used for display purposes only. If ReadOnly is True, TdxDBTreeViewEdit can only be used to display the value of a field on the current record. If ReadOnly is False, the user can use TdxDBTreeViewEdit to edit the field's value.

Page 130 of 172

TdxLookupTreeView
Hierarchy Properties

TLookupTreeView component is a control that combines an edit box with a data-aware tree-view. Unit dxdbtrel Description TLookupTreeView allows you to provide users with a convenient data tree view for populating the Text property that is obtained from another dataset.

Page 131 of 172

TdxLookupTreeView.Alignment
TdxLookupTreeView

Specifies how text is aligned within the edit control. property Alignment: TAlignment; Description These are the possible values of Alignment: Meaning Value taLeftJustify taCenter taRightJustify Align text on the left side of a column. Center text in a column. Align text on the right side of a column.

Page 132 of 172

TdxTreeViewEdit.Alignment
TdxTreeView Edit

Specifies how text is aligned within the edit control. property Alignment: TAlignment; Description These are the possible values of Alignment: Meaning Value taLeftJustify taCenter taRightJustify Align text on the left side of a column. Center text in a column. Align text on the right side of a column.

Page 133 of 172

TCustomdxTreeView Events
TCustomdxTreeView

OnCustomDraw OnDragDropIsCopy OnDragDropTreeNode OnEndDragTreeNode

Page 134 of 172

TCustomdxTreeView Methods
TCustomdxTreeView

DoCustomDraw DoDragDropTreeNode DoDragDropIsCopy IsCustomDraw MoveTreeNodeStructure

Page 135 of 172

TCustomdxTreeView Properties
TCustomdxTreeView

DeletingConfirmationMessage Options SelectedIndex DragSourceTreeNode ShowNodeHint

Page 136 of 172

TdxTreeView Properties
TdxTreeView

Derived from TCustomdxTreeView DeletingConfirmationMessage Options SelectedIndex

Page 137 of 172

TCustomdxTreeView.DeletingConfirmationMessage
TCustomdxTreeView

Specifies the message text which is displayed in the confirmation dialog box when a node is about to be deleted. property DeletingConfirmationMessage: string; Description When an end-user is about to remove a node in the dxTreeView, a message dialog box appears provided that the trConfirmDelete flag is set in the Options property. Use the DeletingConfirmationMessage property to specify a custom message text for this dialog box.

Page 138 of 172

TCustomdxTreeView.DoCustomDraw
TCustomdxTreeView See Also

DoCustomDraw is a protected implementation method for the control's OnCustomDraw event. procedure DoCustomDraw(TreeNode : TTreeNode; Var AFont : TFont; Var AColor, ABkColor : TColor); virtual; Description The DoCustomDraw method does nothing except call any event handler attached to the OnCustomDraw event. When creating a component that descends from the TCustomdxTreeView, override the DoCustomDraw to provide other responses in addition to the inherited event-handler call. Note: This method is overridden in the dxDBTreeView controls.

Page 139 of 172

TCustomdxTreeView.DoDragDropIsCopy
TCustomdxTreeView See Also

DoDragDropIsCopy is a protected implementation method for the control's OnDragDropIsCopy event. procedure DoDragDropIsCopy(Destination, Source : TTreeNode; var IsCopy : Boolean); virtual; Description The DoDragDropIsCopy method does nothing except call any event handler attached to the OnDragDropIsCopy event. When creating a component that descends from the TCustomdxTreeView, override DoDragDropIsCopy to provide other responses in addition to the inherited event-handler call.

Page 140 of 172

TCustomdxTreeView.DoDragDropTreeNode
TCustomdxTreeView See Also

DoDragDropTreeNode is a protected implementation method for the control's OnDragDropTreeNode event. procedure DoDragDropTreeNode(Destination, Source : TTreeNode; Var Accept : Boolean); virtual; Description The DoDragDropTreeNode method does nothing except call any event handler attached to the OnDragDropTreeNode event. When creating a component that descends from the TCustomdxTreeView, override DoDragDropTreeNode to provide other responses in addition to the inherited event-handler call.

Page 141 of 172

TCustomdxTreeView.DragSourceTreeNode
TCustomdxTreeView

Determines the drag source tree node during drag & drop operations. property DragSourceTreeNode: TTreeNode; Description Read Only. Use DragSourceTreeNode to determine the drag source tree node during drag & drop operations. You can use it in drag & drop events.

Page 142 of 172

TCustomdxTreeView.IsCustomDraw
TCustomdxTreeView See Also

Determines whether custom draw is used. function IsCustomDraw : Boolean; virtual; Description Call IsCustomDraw to determine whether custom draw is used. It returns True if custom draw is used and False if not. Custom draw is used if you write code within the OnCustomDraw event handler. Note: This method is overridden in the dxDBTreeView controls.

Page 143 of 172

TCustomdxTreeView.MoveTreeNodeStructure
TCustomdxTreeView

Moves or copies a tree node structure. function MoveTreeNodeStructure(Source, Destination : TTreeNode; IsCopy : Boolean) : TTreeNode; Description The Source parameter determines which tree node to move or copy. The Destination parameter determines where to move or copy the tree node. The Destination and Source tree node may have different TreeViews. The IsCopy parameter determines whether the structure is moved or copied. If IsCopy is True, then the structure is copied. If IsCopy is False, then the structure is moved. The result is the root of the newly created tree node structure.

Page 144 of 172

TCustomdxTreeView.OnCustomDraw
TCustomdxTreeView See Also Example

Occurs when a control is painting a particular tree node by using custom draw services and the Win32 API requests the font and color for this particular tree node. TTreeViewCustomDraw = procedure(Sender : TObject; TreeNode : TTreeNode; Var AFont : TFont; Var AColor, ABkColor : TColor) of object; property OnCustomDraw : TTreeViewCustomDraw; Description Use the OnCustomDraw event handler to implement custom draw services. The OnCustomDraw handler can set the font, color, and background color of the text for a particular TreeNode.

Page 145 of 172

TCustomdxTreeView.OnDragDropIsCopy
TCustomdxTreeView See Also Example

Occurs when a user drags an object over a control or when the user drops an object being dragged. type TDragDropIsCopy = procedure(Destination, Source : TTreeNode; var IsCopy : Boolean) of object; property OnDragDropIsCopy : TdragDropIsCopy; Description Use an OnDragDropIsCopy event to change the dxTreeView drop operation behavior. Within the OnDragDropIsCopy event handler, set IsCopy to True to copy the Source tree node and to False to move the Source tree node. The Source is the tree node being dragged, the Destination is the selected drop target tree node.

Page 146 of 172

TCustomdxTreeView.OnDragDropTreeNode
TCustomdxTreeView See Also Example

Occurs when a user drags an object over a control or when the user drops an object being dragged. TDragDropTreeNode = procedure(Destination, Source : TTreeNode; Var Accept : Boolean) of object; property OnDragDropTreeNode : TDragDropTreeNode; Description Use an OnDragDropTreeNode event to signal that the dxTreeView has to copy. Within the OnDragDropTreeNode event handler, set the Accept parameter to False to reject the dragged object. Set Accept to True to allow the user to drop the dragged object on the control. The Source is the tree node being dragged, the Destination is the selected drop target tree node.

Page 147 of 172

TCustomdxTreeView.OnEndDragTreeNode
TCustomdxTreeView See Also Example

Occurs when a drag & drop operation is successfully finished and before the tree-node(s) (records for data-aware TreeView) are moved (added). TEndDragTreeNode = procedure(Destination, Source : TTreeNode; Var AttachMode : TNodeAttachMode) of object; property OnEndDragTreeNode : TEndDragTreeNode; Description Write an OnEndDragTreeNode event handler to change the default behavior of the dxTreeView on Drop operation. The Destination and Source variants are the destination and Source tree nodes. The AttachMode variant is a set of the possible ways in which the Source can be attached to the Destination. The default value of the AttachMode is naAddChild. Set AttachMode to: naAdd naAddFirst naAddChild naAddChildFirst naInsert Adds the source to the end of the list of the Destination; Adds the source at the beginning of the list of the Destination; Adds the source as a child of the destination at the end of the child list; Adds the source as a child of the destination at the beginning of the child list of the destination; Inserts the source after the destination node.

Page 148 of 172

TCustomdxTreeView.Options
TCustomdxTreeView

Specifies various behavioral properties of the dxTreeView. type TdxTreeViewOption = (trCanDelete, trConfirmDelete); TdxTreeViewOptions = set of TdxTreeViewOption; property Options : TdxTreeViewOptions; Description Set Options to include the desired properties for the dxTreeView. Options is a set drawn from the following values: Meaning Value trCanDelete trConfirmDelete Delete the selected tree node and its structure, when the user presses Delete. A message box appears, asking for confirmation, when the user presses Delete to remove a node in the dxTreeView. The trCanDelete must also be set.

Page 149 of 172

TCustomdxTreeView.SelectedIndex
TCustomdxTreeView

Specifies the index in an image list to be used when an item is selected. property SelectedIndex : Integer; Description Use SelectedIndex to specify the index in an image list to be used when an item is selected.

Page 150 of 172

TCustomdxTreeView.ShowNodeHint
TCustomdxTreeView

Determines if a dxTreeView should display a tree node hint when the mouse pointer rests momentarily on a tree node. property ShowNodeHint : Boolean; Description Set ShowNodeHint to False to prevent tree node hints from displaying within all Express TreeViews. Note: Tree node hint behavior depends on your commctrl.dll version.

Page 151 of 172

TdxDBTreePrintData Properties
TdxDBTreePrintData

MaxLevelCount DataSource KeyField LevelCount ParentField RootValue

Page 152 of 172

TdxDBTreeQRBand Properties
TdxDBTreeQRBand

DataSource IndentationWidth

Page 153 of 172

TdxDBTreePrintData.DataSource
TdxDBTreePrintData See Also

Identifies the link to a self-referenced dataset from where TdxDBTreePrintData locates its data. property DataSource : TDataSource; Description Set DataSource to the TDataSource object that links to a self-referenced dataset from where the TdxDBTreePrintData should fetch its data.

Page 154 of 172

TdxDBTreePrintData.KeyField
TdxDBTreePrintData See Also

Identifies the KEY field of a self-referenced dataset. property KeyField: string; Description Set the KeyField property to the KEY field of the self-referenced dataset. The dataset is specified by a data source component (TDataSource).

Page 155 of 172

TdxDBTreePrintData.LevelCount
TdxDBTreePrintData

Specifies the levels number that TdxDBTreePrintData can load. property LevelCount : Integer; Description Set LevelCount to specify the levels number that TdxDBTreePrintData can load. If the LevelCount equals 0, then TdxDBTreePrintData loads 'root' records and all their children recursively. If the LevelCount equals 1, then TdxDBTreePrintData loads only 'root' records. If the LevelCount equals 2, then TdxDBTreePrintData loads 'root' records and their 'nearest' children, etc.

Page 156 of 172

TdxDBTreePrintData.MaxLevelCount
TdxDBTreePrintData

Determines the maximum level number in TdxDBTreePrintData. property MaxLevelCount : Integer; Description Run-time and Read-Only. Use MaxLevelCount to determine the maximum level number in TdxDBTreePrintData.

Page 157 of 172

TdxDBTreePrintData.ParentField
TdxDBTreePrintData See Also

Identifies the PARENT field of a self-referenced dataset. property ParentField: string; Description Set the ParentField property to the PARENT field of a self-referenced dataset. The dataset is specified by a data source component (TDataSource).

Page 158 of 172

TdxDBTreePrintData.RootValue
TdxDBTreePrintData See Also

Determines the KEY field Value. property RootValue : String; Description Use RootValue to specify the 'root' record. You can make any record of a self-referenced DataSet the root record of TdxDBTreePrintData. If the RootValue is different from NULL, then TdxDBTreePrintData will load only the record whose KEY value equals RootValue and all its children (the children are loaded recursively).

Page 159 of 172

TdxDBTreeQRBand
Hierarchy Properties

TdxDBTreeQRBand control is the QRBand that allows easily making the Quick report with the self-referenced dataset. Unit dxdbtrqr Description Use TdxDBTreeQRBand to make the Quick report with the self-referenced dataset. TdxDBTreeQRBand increases the left property of its child controls depending on the IndentationWidth and the TdxDBTreePrintDataSet record Level.

Page 160 of 172

TdxDBTreeQRBand.DataSource
TdxDBTreeQRBand See Also

DataSource identifies the link to the TdxDBTreePrintData dataset. property DataSource : TDataSource; Description Set DataSource to identify the link to the TdxDBTreePrintData dataset.

Page 161 of 172

TdxDBTreeQRBand.IndentationWidth
TdxDBTreeQRBand

IndentationWidth specifies the indentation in pixels for one level. property IndentationWidth : Integer; Description Use IndentationWidth to specify in pixels the indentation for one level. TdxDBTreeQRBand increases the left property of its child controls in the following way: for I := 0 to ControlCount - 1 do Controls[I].Left := Controls[I].Left + IndentationWidth * DBTreeQRBand.FindField ('dx$level').AsInteger;

Page 162 of 172

Unit dxdbtrqr
Controls TdxDBTreeQRBand

Page 163 of 172

Example
This example shows how to use the OnCustomDraw event. Nodes that have a KeyValue less than 150 are drawn with bold font style and blue font color, while all other nodes are drawn with the Red color style on a yellow background. procedure TForm1.DBTreeView1CustomDraw(Sender: TObject; TreeNode: TTreeNode; AFont: TFont; var AColor, ABKColor: TColor); Var KeyValue : Integer; begin if VarIsNull(TdxDBTreeNode(TreeNode).KeyFieldValue) then exit; //Get Key Value of a particular node. KeyValue := TdxDBTreeNode(TreeNode).KeyFieldValue; //Change the Font Style, Color and Background Color of a node based on it's KeyValue; if(KeyValue < 150) then begin AFont.Style := [fsBold]; AColor := clBlue; end else begin ABKColor := clYellow; AColor := clRed; end; end;

Page 164 of 172

Example
In this example we use the OnNewKeyValue to get the KeyValue for a newly created node from DB. procedure TForm1.dxDBTreeViewCreateNewKeyValue(Sender: TObject; var NewKeyValue: Variant); begin GetMaxIdQuery.SQL.Clear; GetMaxIdQuery.SQL.Add('Select max(id) From Products'); GetMaxIdQuery.Open; NewKeyValue := GetMaxIdQuery.Fields[0].AsInteger + 1; GetMaxIdQuery.Close; end;

Page 165 of 172

Example
In this example we use the OnAddNewItem event and the BkColor, Color, FontStyle, FontName and IsCustomDraw properties of the TdxDBTreeNode to implement custom drawing in a TdxDBTreeView. procedure TForm1.dxDBTreeView1AddNewItem(Sender: TObject; var DBTreeNode: TdxDBTreeNode); begin case Table1.FindField('state').AsInteger of 0: with DBTreeNode do begin FontStyle := []; Color := clGreen; BkColor := clWhite; end; 1: with DBTreeNode do begin FontStyle := [fsBold]; Color := clRed; BkColor := clYellow; end; 2: with DBTreeNode do begin FontStyle := [fsBold]; Color := clWhite; BkColor := clBlack; end; 3: with DBTreeNode do begin FontStyle := [fsItalic]; Color := clBlue; BkColor := clWhite; end; 4: with DBTreeNode do begin FontStyle := [fsUnderLine]; Color := clSilver; BkColor := clWhite; end; end; DBTreeNode.IsCustomDraw := True; end;

Page 166 of 172

Example
In this example we use the OnEndDragTreeNode event to change the drag & drop behavior of the TdxTreeView in the following way: If the Source and Destination tree nodes are at the same level, then the source tree node is inserted before the destination (Default Behavior the source tree node becomes the last child tree node of the destination). procedure TForm2.DBTreeView1EndDragTreeNode(Destination, Source: TTreeNode; var AttachMode: TNodeAttachMode); begin // naAdd, naAddFirst, naAddChild, naAddChildFirst, naInsert if Destination.Level = Source.Level then AttachMode := naInsert; if Destination.Level = Source.Level - 1 then AttachMode := naAddChild; end;

Page 167 of 172

Example
In this example we use the OnSetDisplayItemText event to change the text of tree nodes based on the tree node level. Tree nodes may display any text, but you will can only edit Text that is required from the field ListField. procedure TForm1.dxDBTreeViewSetDisplayItemText(Sender: TObject; var DisplayText: string); Var tr : TTreeNode; begin // Get TreeNode tr := dxDBTreeView.DBTreeNodes.GetTreeNode(TreeQueryID.Value); if tr <> Nil then begin if tr.Level mod 2 = 1 then DisplayText := Field1.Text else DisplayText := Field2.Text; end; end;

Page 168 of 172

Example
In this example we use the DBTreeNodes.MaxKeyFieldValue property of a dxDBTreeView to set up the KeyField in a Table. procedure TForm1.T1AfterInsert(DataSet: TDataSet); begin if varIsNull(T1.FindField('pr_id').Value) then begin if varIsNull(dxDBTreeView1.DBTreeNodes.MaxKeyFieldValue) then T1.FindField('pr_id').AsInteger := 0 else T1.FindField('pr_id').Value := dxDBTreeView1.DBTreeNodes.MaxKeyFieldValue + 1; end; end;

Page 169 of 172

Example
In the following example, we disable drag & drop for root nodes. procedure TForm1.DBTreeView1DragDropTreeNode(Destination, Source: TTreeNode; var Accept: Boolean); begin Accept := Not (Source.Parent = Nil); end;

Page 170 of 172

Example
In the following example, we copy the tree node structure during drag & drop even if the user does not press the CTRL key. procedure TForm1.DBTreeView2DragDropIsCopy(Destination, Source: TTreeNode; var IsCopy: Boolean); begin IsCopy := True; end;

Page 171 of 172

Example
In this example we display the number of children of a selected node. This code should be used only with the SmartRecordLoad option. procedure TForm1.Button1Click(Sender: TObject); begin if dxDBTreeView1.Selected <> nil then begin with TdxDBTreeNode(dxDBTreeView1.Selected) do begin //Check if child records are loaded. if ChildLoaded then ShowMessage(IntToStr(Count)) else begin //Load child records ChildLoaded := True; ShowMessage(IntToStr(Count)); ChildLoaded := False; end; end; end; end;

Page 172 of 172

Das könnte Ihnen auch gefallen