TmsDBTreeView

version 1.0 (last modified August, 27, 2005)


Copyright © 2002 - 2005 mSunSoftware
All rights reserved.

e-mail: support@msunsoftware.com
web site: http://www.vcl.msunsoftware.com/

Contents
Hierarchy:

TObject
     |
TPersistent
     |
TComponent
     |
TControl
     |
TWinControl
     |
TCustomTreeView


Description:

TmsDBTreeView represents a window that displays a hierarchical list of nodes, where each node is connected with the Database record. The component supports two types of the nodes: folders and files. A folder can include other nodes, and it is not connected with Database records containing the data. A file cannot include other nodes, but it is connected with the Database record, which contain the data. Each node is identified by four fields (a name, a status, a type, a position); each of the fields rewrites when its value is changing. The component supports the 'drag and drop' operation. For operations of addition, deletion, renaming of the nodes, uses shortcuts (Ins, Ctrl+ Ins, Del). The component works with the DataSet heirs. This component can be used for creation of the programs of a class of the information managers, various explorers etc.


Properties:
  • property Active: boolean;
    Indicates whether the component is active.
    Description:
    Use Active to set the component in active or in passive status. When Active is accepting true value, the data are loading from the Database table, there are the nodes of a tree creating and initializing, according to structure determined in the Database; all the methods is becoming accessible. But the connection with the Database must be already set! When Active is accepting false value, the component is setting in a passive status, all the nodes of a tree are removing (if they were created before); all methods are becoming inaccessible, besides the Open method.
    Note:
    Calling the Open method sets Active to true; calling the Close method sets Active to false. Calling the Reopen method is initializing the data secondary. You should open a connection with a Database before set Active to true, and close a connection with a Database after set Active to false.
    Warning:
    The status Active does not influence on connection with a Database.
  • property DataSet: TDataSet;
    Defines a data set.
    Description:
    As a data set, you can use any heir TDataSet. The value DataSet can be established, both during designing, and in execution time of the application. But the connection with the Database must be already set before calling of the method Open (or set Active in true).
    Warning:
    For normal work of a component, in the Database table, connected by you, there should be following fields:




    name  type  size
    ID counter long int
    OwnerID numeric int
    Type numeric int
    State numeric int
    Title string int



  • property IconIndexes: TIconIndexes;
    Specifies icon index from ImageList, for various types of the nodes (a root node, a folder, a file).
    Description:
    The type TIconIndexes is defined as class with three fields:


    Root_ImageIndex icon index for a root node;
    Folder_ImageIndex icon index for a folder;
    Record_ImageIndex icon index for a file;


  • property TypeOfSelected: boolean;
    The type of the selected node (a folder or a file).
    Description:
    Value of the TypeOfSelected changes when you select a new node. If the folder is selected, then TypeOfSelected equal 0. If the file is selected, then TypeOfSelected equal 1.
    Note:
    The status of a TypeOfSelected is convenient for tracing in an OnSelectNode event handler.

Methods:
  • procedure AddNode(const _type: integer); virtual;
    Adds the new node in the current folder.
    Description:
    You can use the AddNode method, to add a new file or a folder. There is a new record is added in a Database when you add a new node. The type of the creating node is the parameter _type. If you want to add a folder then parameter _type is FOLDER_TypeOfNode (0), if you want to add a file then parameter _type is - RECORD_TypeOfNode (1). The new node adds to selected folder.
  • procedure DelNode(); virtual;
    Deletes the selected node.
    Description:
    You can use the DelNode method to delete the selected node At deleting of the node, there is a record Database which this node points to, deletes also.
    Note:
    When deleting a folder, you remove all the nodes inside that folder as well.
    Warning:
    You can't delete the root folder. When you try to delete the root folder there is a window with warning arise.
  • procedure Open(); virtual;
    Creates the nodes, set a component in the active status.
    Description:
    You can use the Open method to set Active in true. When Active is accepting true value, the data are loading from the Database table, there are the nodes of a tree creating and initializing, according to structure determined in the Database; all the methods is becoming accessible. But the connection with the Database must be already set!
    Warning:
    The status Active does not influence on connection with a Database. You should open a connection with a Database before calling the Open method.
  • procedure Reopen(); virtual;
    Initializing the data secondary.
    Description:
    You should to call the Reopen method to initialize the data secondary.
    The secondary initialization of the data can be required at change of a Database in the working time of the application. After calling of this method, Active sets in true.
    Note:
    The Reopen method calls the methods Close and Open.
  • procedure Close(); virtual;
    Deletes all the nodes, translates a component in the passive status.
    Description:
    You can use the Close method to set Active in false. When Active is accepting false value, the component is setting in a passive status, all the nodes of a tree are removing (if they were created before); all methods are becoming inaccessible, besides the Open method.
    Warning:
    The status Active does not influence on connection with a Database. You should close a connection with a Database after calling the Close method.

Events:
  • property OnBeforeAddNode: TNodeAction;
    type TNodeAction = procedure (Sender: TObject; _type : integer; var Confirm : boolean) of object;
    Occurs before adding of the node.
    Description:
    You can use an OnBeforeAddNode event handler to request the user a confirmation for addition of the new node, or, define special conditions at which new node can not be added. For this purpose you should use parameter Confirm such as boolean, which defines whether the new node will be added. Parameter _type is pointing to the type of the deleting node (0 - a folder, 1 - a file). 
    The type TNodeAction point to method, which processes creation of the new node. The value of a parameter Confirm confirms or cancels addition of the new node.
  • property OnBeforeDelNode: TNodeAction;
    type TNodeAction = procedure (Sender: TObject; _type : integer; var Confirm : boolean) of object;
    Occurs before deleting of the node.
    Description:
    You can use an OnBeforeDelNode event handler to request the user a confirmation for deleting of the node, or, to define special conditions, at which the node can not be removed. For this purpose you should use parameter Confirm such as boolean, which defines, whether the node will be removed. Parameter _type is pointing to the type of the deleting node (0 - a folder, 1 - a file).
    The type TNodeAction specifies a method, which processes deleting of the node. The value of a parameter Confirm confirms or cancels a deleting of the node. 
    Note:
    The event does not occurs if you try to delete a root folder.
  • property OnBeforeOpen : TComponentAction;
    type TComponentAction = procedure (Sender: TObject) of object;
    Occurs before transition of a component in a active status.
    Description:
    You can use an OnBeforeOpen event handler to define special actions before activation of a component. For example, to open connection with Database.
  • property OnAfterClose : TComponentAction;
    type TComponentAction = procedure (Sender: TObject) of object;
    Occurs after transition of a component in a passive status.
    Description:
    You can use an OnAfterClose event handler to define special actions after transition of a component in a passive status. For example, to close connection with a Database.
  • property OnSelectNode: TSelectNode;
    type TSelectNode = procedure (Sender: TObject; Node: TTreeNode) of object;
    Occurs at transition to the new node.
    Description:
    Use an OnSelectNode event handler to define special actions at transition to the new node. At transition to the new node, the cursor is pointing to a Database record, which is connected with the allocated node. Parameter _Node specifies the allocated node. 
    Note:
    It is comfortable to trace a status TypeOfSelected in an the OnSelectNode event handler.

Copyright © 2002 - 2005 mSunSoftware. All rights reserved.