📄 readme.txt
字号:
TTreeViewEx:
This is an extended TTreeView component.
TDBTreeView:
A data-aware TTreeView component.
TDbTreeLookupComboBox:
A DBLookupComboBox that shows a DBTreeView instead of a list.
Version 0.83 Nov-01-1997
(C) 1997 Christoph R. Kirchner
!! This component is currently UNDER CONSTRUCTION !!
Thanks to Maxim Monin for his TDBOutline-component I could start with.
Thanks to Peter M. Jagielski (73737.1761@compuserve.com) for
contributing an idea how to get the rect a window can use without
getting hidden by the Win95-Taskbar. (He published a procedure
SizeForTaskBar in sizetask.zip).
Description:
The TDBTreeView component allows you to reflect your hierarchical
data from a dataset in the form of a tree. This component descended
from TCustomTreeView and has all of its features. But source data
are taken from a table instead of the Lines property.
The TDbTreeLookupComboBox component is a DBLookupComboBox that
allows it to select hierarchical data from a table in a TreeView.
Properties of TDBTreeView:
DataSource: TDataSource
This property have all data-aware controls.
DataSet: TDataSet, runtime and read-only
DataSource.DataSet
SelectedID: LongInt, runtime only
The ID of the current selected node
IDs[Index: LongInt]: LongInt, runtime and read-only
The ID of Item[Index]. Index is 0 to Items.Count -1
TableIDField:
The integer-field with this name contains the record ID.
If DataSource is a TTable, the IDField must have the primary
index.
TableParentField:
The integer-field with this name contains reference to parent
ID. If DataSource is a TTable, the ParentField must have a
secondary index.
TableTextField:
Table field with this name contains text string for output.
RootID: LongInt
Specifies tree root ID.
RSelected: TTreeNode
The last node that was clicked with the right mouse-button.
Options:
dtAutoDragMove:
The user can move items by dragging them in the DBTreeView.
The parent-field of the record of the moved item will be set
to the ID of the new parent automatically.
dtAutoExpand:
The tree will get expanded completely after building.
dtAutoShowRoot:
The ShowRoot property specifies whether lines connecting root
(top-level) items are displayed. If dtAutoShowRoot is in
Options, the DBTreeView will set the ShowRoot property itself,
depending on the numbers of root-items: If are more then one
of them, the DBTreeView will set the ShowRoot property to True,
otherwise it will set the ShowRoot property to False.
ShowRoot = True will show lines connecting the root items if
the ShowLines property is True, and If ShowButtons is set to
True, a button ([+] or [-]) will appear to the left of each
root item.
dtCancelOnExit:
An insertion-operation get canceled if the user leaves the
DbTreeView without changing the inserted record. This avoids
empty records in the table. DtCancelOnExit is similar to
dgCancelOnExit of TDBGrid.
dtConfirmDelete:
The user gets asked if he really want to delete the current
record after he pressed the Del-key or the record is to be
deleted by a navigation-button.
dtFocusOnEdit:
If the dataset changes to edit- or insert-mode, the DbTreeView
will get the focus. This allows to user to edit the tree-node
directly after pressing edit or insert on a navigation-button.
Also, if the dateaset is in edit- or insert-mode and the
DbTreeView receives the focus, the selected node goes into the
edit-mode. Please do not set dtFocusOnEdit if there is a TDBEdit,
TDBMemo or TDBGrid on the form connected to the same dataset -
the user could get confused too much. Also, please set
dtSynchronizeDataSet too if you use dtFocusOnEdit.
Setting dtFocusOnEdit is recommended if there is - more or less -
only a DbTreeView and a DBNavigator on the form.
dtInsertAsChild:
The new item that is created by pressing the insert key gets
inserted after the selected node if tveInsertAsChild is false
or it gets inserted as a child of the selected node if
tveInsertAsChild is true.
dtMouseMoveSelect:
If the user moves the mouse, the nearest node gets selected.
If the user moves the mouse to the upper or lower border of
the DbTreeView while left button pressed, the DbTreeView will
scroll. This scrolling happens anyway if the user drags a node.
The option dtMouseMoveSelect makes sense if the DbTreeView is
shown in a dropdown-panel.
dtRebuildFocusedOnly:
If dtRebuildFocusedOnly is in Options, the DbTreeView will not
rebuild the tree after the dataset changed unless the DbTreeView
gets the focus. This is not set by default. The TDbTreeLookup-
ComboBox uses this option to avoid needless rebuilds of the
DbTreeView in the dropdown-panel until it gets visible.
dtRootItemReadOnly:
If there is a record in the table with the ID of RootID, then
you can set it to read-only by setting RootItemReadOnly to true.
dtSynchronizeDataSet:
The current selected treenode will always represent the current
record of the DataSet. If not dtSynchronizeDataSet in Options,
selecting treenodes gets faster.
Events:
OnClosedLoop: TNotifyEvent
- is called when the component detects cyclic references.
OnRootNotFound: TNotifyEvent
- is called if there is at least one record in the dataset, but
none of it has the root-ID.
property OnGetNextID: TDBTVGetNextIDEvent
function (Sender: TObject; DataSet: TDataSet): string
- Called by the procedure Insert, OnGetNextID has to calculate the
ID of a new record. This is not needed if the type of the ID-field
is ftAutoInc. You have to override GetNewID if you hide the record
with the highest ID and the type of the ID-field is not ftAutoInc:
- DataSet is TQuery and TQuery.SQL uses 'WHERE ...'
- DataSet.MasterSource is set.
If you use a TQuery as Dataset, it is recommended to calculate the
new ID yourself.
If you set the new ID on Dataset.OnNewRecord, please use OnGetNextID
or your own GetNewID bacause the ID is needed before the Dataset gets
into insert-mode.
Methods:
procedure RebuildTree;
Rebuilds the tree if possible
function GetNewID: Longint; virtual;
Same as OnGetNextID
function GetExpanded(Separator: Char): String;
procedure SetExpanded(const List: String; Separator: Char);
With GetExpanded you can save all Items[].Expanded in a
string (e.g. to save this in an INI-file) to restore all
Items[].Expanded with SetExpanded.
procedure SynchronizeSelectedNodeToCurrentRecord;
If not dtSynchronizeDataSet in Options, use this procedure
to show the current record of the dataset in the tree.
procedure SynchronizeCurrentRecordToSelectedNode;
If not dtSynchronizeDataSet in Options, use this procedure
to move the dataset to the selected node of the tree.
function IDOfNode(Node: TTreeNode): Longint;
To get the ID of a Node.
Global:
var sdbtvDefaultDeleteQuestion: string
The question the user will get if he wants to delete a record.
You can include a '%s' to show the label of the TreeNode that
gets deleted.
You can overwrite the function
GetDeleteQuestion(Node: TTreeNode): string;
to customize this question for a single DBTreeView.
Properties of TDbTreeLookupComboBox:
TreeSelect: TTreeSelect, runtime only
The dropdown-panel.
DBTreeViewDataset: TDataset, runtime and readonly
The dataset of the DBTreeView of the dropdown-panel.
ListTree...
Properties of the DBTreeView of the dropdown-panel.
Options:
dtAcceptLeavesOnly:
The User can only select nodes that have no children.
If you use the event OnAcceptNode, Accept is set to false if
the node has children. But you can accept the node anyway by
setting Accept to true.
dtDontAcceptRoot:
The User can not select the root-node.
If you use the event OnAcceptNode, Accept is set to false if
the node is the root-node. But you can accept the node anyway
by setting Accept to true.
dtKeepDataSetConnected:
The DataSource TDbTreeLookupComboBox.ListSource or the
LookupDataSet of TDbTreeLookupComboBox.ListField will be
always connected to the TDBTreeView of the dropdown-panel.
If you set dtKeepDataSetConnected to false, a complete
rebuild of the tree is needed before each dropdown.
Events:
OnAcceptNode: TAcceptNodeEvent
(Node: TTreeNode; var Accept: Boolean)
Here you can decide if the selected node is valid. If you
set Accept to False, the dropdown-panel will not close up.
It gets called if the user selects a value, does a quick-
search (typing the first letters of the searched value into
the combo-box) or is moving through the data with the cursor-
up or cursor-down keys.
OnCreateTreeSelect: TCreateTreeSelectEvent
This event gets called before the first dropdown.
You can use this event to create a special TreeSelect-form
for the DbTreeLookupComboBox. This form will get destroyed by
its owner, so at DbTreeLookupComboBox.CreateTreeSelect you
can write "result := TFormX.Create(self);".
Methods:
procedure PrepareDropdown:
You can use PrepareDropdown to build the tree of the dropdown-
panel before first dropdown happens (datasets have to be open
already) - the first dropdown will get faster then.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -