Copyright: Copyright © 1998-2007 Developer Express Inc.,  ALL RIGHTS RESERVED
Citation: Copyright © 1998-2007 Developer Express Inc.,  ALL RIGHTS RESERVED  This program and all its contents are protected by US Copyright Laws and International Treaties.  Any unauthorized duplication, distribution and reproduction are prohibited.


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.


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.


Unit dxdbtree

Controls

TdxDBTreeView

Objects

TdxDBTreeNodes

TdxDBTreeNode


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.


Hierarchy

TCustomTreeView

     |

TCustomdxTreeView

     |


TdxDBTreeView Properties

TdxDBTreeView

   DBSelected

     DBTreeNodes

   DataSource

   DisplayField

   ImageIndexField

   KeyField

   ListField

   ParentField

   RootValue

   SeparatedSt

   StateIndexField

   Options

Derived from TCustomdxTreeView

   DeletingConfirmationMessage

   Options

   SelectedIndex


TdxDBTreeView Methods

TdxDBTreeView

  GetImageIndexField

  GetKeyField

  GetListField

  GetParentField

  GetStateIndexField

  GotoKeyFieldValue

  IsCustomDraw

  RefreshItems


TdxDBTreeView Events

TdxDBTreeView

   OnAddNewItem

   OnCreateNewKeyValue

   OnSetDisplayItemText


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);


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.


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.


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 TreeNode’s Text. You have to use this property if you wish to display more than one field or a field different from the ListField.


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.


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).


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).


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).


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).


TdxDBTreeView.SeparatedSt

TdxDBTreeView            See Also

Determines the string which is used as a separator between values of different fields in a Tree Node’s 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 Node’s Text, once the DisplayField property is assigned. The default value is ' - '.


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.


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	Meaning
trDBCanDelete	Deletes the selected tree node and its structure, when the user presses the Delete key.
trDBConfirmDelete	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.
trCanDBNavigate	On changing the DB cursor in a linked DataSet, the selected tree node is also changed.
trSmartRecordLoad	DBTreeView uses the smart record loading feature.
trSmartRecordCopy	On drag & drop events, copies the associated data in the dataset. By default the Key, Parent and Name fields are the only items copied.
trCheckHasChildren	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.


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.


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.


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.


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.


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.


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.


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.


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.


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.


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.


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.


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.


Hierarchy

TObject

     |


TdxDBTreeNodes Properties

TdxDBTreeNodes

  Items

  MaxKeyFieldValue


TdxDBTreeNodes Methods

TdxDBTreeNodes

  Count

  GetKeyFieldValue

  GetParentValue

  GetDBTreeNode

  GetTreeNode


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];


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.


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.


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.


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.


TdxDBTreeNodes.GetDBTreeNode

TdxDBTreeNodes

Returns DBTreeNode items by its KeyValue.

function GetDBTreeNode(Value : Variant) : TDBTreeNode;

Description

Call GetDBTreeNode to return DBTreeNode items by its KeyValue.


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.


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.


Hierarchy

TTreeNode

     |


TdxDBTreeNode Properties

TdxDBTreeNode

     BkColor

     Color

     FontStyle

     FontName

     IsCustomDraw

   ChildLoaded

   KeyFieldValue

   ParentFieldValue


TdxDBTreeNode Methods

TdxDBTreeNode

  LoadChildren


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.


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.


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.


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.


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.


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.


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.


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.


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.


Unit dxdbtrel

Controls

TCustomdxVTreeViewEdit

TCustomdxTreeViewEdit

TdxTreeViewEdit

TdxDBTreeViewEdit

TCustomdxLookupTreeView

TdxLookupTreeView

TdxDBLookupTreeView


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).


Hierarchy

TCustomControl

     |


TCustomdxVTreeViewEdit Properties

TCustomdxVTreeViewEdit

   DividedChar

   TextStyle

     Selected

   CanSelectParents

   DropDownRows

   DropDownWidth

   Text

   TreeViewColor

   TreeViewCursor

   TreeViewFont

   TreeViewHint

   TreeViewImages

   TreeViewIndent

   TreeViewPopupMenu

   TreeViewReadOnly

   TreeViewShowButtons

   TreeViewShowHint

   TreeViewShowLines

   TreeViewShowRoot

   TreeViewSortType

   TreeViewStateImages


TCustomdxVTreeViewEdit Methods

TCustomdxVTreeViewEdit

  CloseUp

  DropDown


TCustomdxVTreeViewEdit Events

TCustomdxVTreeViewEdit

   OnCloseUp

   OnCustomDraw

   OnDropDown

   OnGetSelectedIndex

   OnGetImageIndex


TCustomdxVTreeViewEdit.DividedChar

TCustomdxVTreeViewEdit            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'.


TCustomdxVTreeViewEdit.TextStyle

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.Selected

TCustomdxVTreeViewEdit

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.


TCustomdxVTreeViewEdit.CanSelectParents

TCustomdxVTreeViewEdit

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.


TCustomdxVTreeViewEdit.DropDownRows

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.DropDownWidth

TCustomdxVTreeViewEdit            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 drop-down 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.


TCustomdxVTreeViewEdit.Text

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.TreeViewColor

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.TreeViewCursor

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.TreeViewFont

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.TreeViewHint

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.TreeViewImages

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.TreeViewIndent

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.TreeViewPopupMenu

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.TreeViewReadOnly

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.TreeViewShowButtons

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.TreeViewShowHint

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.TreeViewShowLines

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.TreeViewShowRoot

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.TreeViewSortType

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.TreeViewStateImages

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.CloseUp

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.DropDown

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.OnCloseUp

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.OnCustomDraw

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.OnDropDown

TCustomdxVTreeViewEdit            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.


TCustomdxVTreeViewEdit.OnGetSelectedIndex

TCustomdxVTreeViewEdit

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.


TCustomdxVTreeViewEdit.OnGetImageIndex

TCustomdxVTreeViewEdit

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.


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.


Hierarchy

TCustomControl

     |

TCustomdxVTreeViewEdit

     |


TCustomdxTreeViewEdit properties

TCustomdxTreeViewEdit

In TCustomdxTreeViewEdit

   Items

Derived from TCustomdxVTreeViewEdit

   DividedChar

   TextStyle


TCustomdxTreeViewEdit Methods

TCustomdxTreeViewEdit

  GetTreeNodeByText


TCustomdxTreeViewEdit.Items

TCustomdxTreeViewEdit

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.


TCustomdxTreeViewEdit.GetTreeNodeByText

TCustomdxTreeViewEdit

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.


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.


Hierarchy

TCustomControl

     |

TCustomdxVTreeViewEdit

     |

TCustomdxTreeViewEdit

     |


TdxTreeViewEdit properties

TdxTreeViewEdit

   Alignment


TdxTreeViewEdit.Alignment

TdxTreeViewEdit

Specifies how text is aligned within the edit control.

property Alignment: TAlignment;

Description

These are the possible values of Alignment:

Value	Meaning
taLeftJustify	Align text on the left side of a column.
taCenter	Center text in a column.
taRightJustify	Align text on the right side of a column.


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.


Hierarchy

TCustomControl

     |

TCustomdxVTreeViewEdit

     |

TCustomdxTreeViewEdit

     |


TdxDBTreeViewEdit Properties

TdxDBTreeViewEdit

     Field

   DataField

   DataSource

   ReadOnly


TdxDBTreeViewEdit.Field

TdxDBTreeViewEdit            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.


TdxDBTreeViewEdit.DataField

TdxDBTreeViewEdit            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.


TdxDBTreeViewEdit.DataSource

TdxDBTreeViewEdit            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.


TdxDBTreeViewEdit.ReadOnly

TdxDBTreeViewEdit            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.


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.


Hierarchy

TCustomControl

     |

TCustomdxVTreeViewEdit

     |


TCustomdxLookupTreeView Properties

TCustomdxLookupTreeView

In TCustomdxLookupTreeView

   AssignField

   DisplayField

   ImageIndexField

   ListSource

   KeyField

   ListField

   Options

   ParentField

   RootValue

   StateIndexField

Derived from TCustomdxVTreeViewEdit

   DividedChar

   TextStyle


TCustomdxLookupTreeView Events

TCustomdxLookupTreeView

   OnAddNewItem

   OnSetDisplayItemText


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.


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.


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.


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.


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.


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.


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.


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.


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.


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.


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 tree-view.  Use it, for example, to assign the ImageIndex, SelectedIndex and StateIndex property of a tree node item.


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.


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.


Hierarchy

TCustomControl

     |

TCustomdxVTreeViewEdit

     |

TCustomdxLookupTreeView

     |


TdxLookupTreeView properties

TdxLookupTreeView

  Alignment


TdxLookupTreeView.Alignment

TdxLookupTreeView

Specifies how text is aligned within the edit control.

property Alignment: TAlignment;

Description

These are the possible values of Alignment:

Value	Meaning
taLeftJustify	Align text on the left side of a column.
taCenter	Center text in a column.
taRightJustify	Align text on the right side of a column.


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.


Hierarchy

TCustomControl

     |

TCustomdxVTreeViewEdit

     |

TCustomdxLookupTreeView

     |


TdxDBLookupTreeView properties

TdxDBLookupTreeView

     Field

   DataField

   DataSource

   ReadOnly


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.


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.


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.


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.


Unit dxtree

Controls

TCustomdxTreeView

TdxTreeView


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.


Hierarchy

TCustomTreeView

     |


TCustomdxTreeView Properties

TCustomdxTreeView

   DeletingConfirmationMessage

   Options

   SelectedIndex

   DragSourceTreeNode

   ShowNodeHint


TCustomdxTreeView Methods

TCustomdxTreeView

   DoCustomDraw

   DoDragDropTreeNode

   DoDragDropIsCopy

     IsCustomDraw

     MoveTreeNodeStructure


TCustomdxTreeView Events

TCustomdxTreeView

  OnCustomDraw

  OnDragDropIsCopy

  OnDragDropTreeNode

  OnEndDragTreeNode


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.


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:

Value	Meaning
trCanDelete	Delete the selected tree node and its structure, when the user presses Delete.
trConfirmDelete	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.


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.


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.


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.


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.


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.


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.


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.


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.


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.


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.


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.


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	Adds the source to the end of the list of the Destination;
naAddFirst	Adds the source at the beginning of the list of the Destination;
naAddChild	Adds the source as a child of the destination at the end of the child list;
naAddChildFirst	Adds the source as a child of the destination at the beginning of the child list of the destination;
naInsert	Inserts the source after the destination node.


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


Hierarchy

TCustomTreeView

     |

TCustomdxTreeView

     |


TdxTreeView Properties

TdxTreeView

Derived from TCustomdxTreeView

   DeletingConfirmationMessage

   Options

   SelectedIndex


Unit dxtrprds

Components

TdxDBTreePrintData


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	Description
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.
dx$Level	The level of a record. The first level (level of the 'root' records) is 0.
dx$recno	The number of a record. The first number is 1.


Hierarchy

TMemData

     |


TdxDBTreePrintData Properties

TdxDBTreePrintData

  MaxLevelCount

  DataSource

  KeyField

  LevelCount

  ParentField

  RootValue


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.


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.


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).


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).


TdxDBTreePrintData.LevelCount

TdxDBTreePrintData

Specifies the level’s number that TdxDBTreePrintData can load.

property LevelCount : Integer;

Description

Set LevelCount to specify the level’s 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.


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).


Unit dxdbtrqr

Controls

TdxDBTreeQRBand


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.


Hierarchy


TdxDBTreeQRBand Properties

TdxDBTreeQRBand

  DataSource

  IndentationWidth


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.


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;


Example1
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;


Example2
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;


Example3
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;


Example4
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;


Example5
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;


Example6
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;


Example7
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;


Example8
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;


Example9
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;


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 ?

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.

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;

// 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;

// 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;