TmsDBTreeView component

| Version 1.0.068 (Last modified December 22, 2006) |

 
 
 

Copyright © mSunSoftware. 2006.
All rights reserved.

E-mail: support@msunsoftware.com
Web: http://www.msunsoftware.com

 
 
 
 
Home english | russian
 
 
 
 

Contents


 
 

Description

The component TmsDBTreeView is a child of TmsTreeView. This one is for the work with data. TmsDBTreeView works with DataSet as the standard VCL components from the Data Controls page (supports all the methods for management of the data). Every node in the component is connected to database record, and is identified by three fields: name, type, state. List of items consist from the objects, which are the childclasses TmsTreeNode - TmsDBTreeNode.


 
 

Hierarchy

TObject
       |
TPersistent
       |
TComponent
       |
TControl
       |
TWinControl
       |
TmsBaseTreeView
       |
TmsCustomTreeView
       |
TmsCustomDBTreeView
       |
TmsDBTreeView


 
 

Class TmsDBTreeNode

Properties

  • property ID: Integer;
    It shows the absolute identifier of the node.
    Description:
    The ID property points to the unique DataSet record. The property is being initialized when the node is loaded from the DataSet or the node is added in the tree.

Methods

  • constructor Create(AOwner: TmsBaseTreeNodes); override;
    Creates and initializes a new TmsDBTreeNode object.
  • procedure Assign(Source: TPersistent); override;
    Copies the Source node data to the Self node.
    Description:
    Use the Assign method to copy the Source node data to the Self node. If the Source is not the object of the TmsDBTreeNode type or the operation is being executing between different Trees (Source.TreeView <> Self.TreeView), then the parent Assign method is called, and the "Text" field (of the Dataset record, associating with the Self node) is updated. Otherwise (Source is TmsDBTreeNode), all the fields of the DataSet record (associating with the Source node) are being copied in the fields of the DataSet record (associating with the Self node). During the Assign operation the DataSet is being blocked with the BeginEdit - EndEdit methods.
  • procedure Delete; override;
    Deletes a node.
    Description:
    Use the DeleteNode method to delete the Self node. When the given method is being called, from the DataSet record (associating with the Self node) is deleted, too. During the Delete operation the DataSet is being blocked with the BeginEdit - EndEdit methods.
    Note:
    Also, for deleting the nodes you can use the Items.Delete, TmsDBTreeView.DeleteNode methods (the record, associating with the deleting node, will be deleted when these methods is called). Don't use the Node.Free method to delete node, as only the node will be deleted without the DataSet record deleting.
  • procedure MoveTo(Destination: TmsBaseTreeNode; Mode: TNodeAttachMode); override;
    Moves the node Self to another location in a tree view control.
    Description:
    Use the MoveTo method for moving the node Self into the new position. After moving the node, the "ParentID" field will be updated. During the MoveTo operation the DataSet is being blocked with the BeginEdit - EndEdit methods.

 
 

Class TmsDBTreeNodes

Methods

  • function AddNode(Node, Relative: TmsBaseTreeNode; const S: string; Ptr: Pointer; Method: TNodeAttachMode): TmsBaseTreeNode; override;
    Adds a new node to a tree view control.
    Description:
    Use the method AddNode to add a new node into a tree view control. If the TmsDBTreeView component isn't active (TVActive = false), then the node won't be added, and the STVIsntActive error will be generated. If the component is active, then the node will be added, and if the Tree isn't being built (TVBuilding = false), then a new record to the DataSet will be added. During the AddNode operation the DataSet is being blocked with the BeginEdit - EndEdit methods.
    Note:
    Besides to add a new node, you can use the following methods: Add, AddFirst, Insert, AddChild, AddChildFirst, AddObject, AddObjectFirst, InsertObject, AddChildObject, AddChildObejectFirst.
  • procedure Assign(Source: TPersistent); override;
    Copies the data from the Source to the Self.
    Description:
    Use the Assign method for coping the data from the Source to the Self. If the TmsDBTreeView component isn't active (TVActive = false), then the data won't be copied, and the STVIsntActive error will be generated. If the component is active, then the data will be copied and the DataSet will be blocked with the BeginEdit - EndEdit methods.
  • procedure Clear; override;
    Deletes all the nodes of the tree.
    Description:
    Use the Clear method to delete all the nodes of the tree. If the component TmsDBTreeView isn't active (TVActive = false), then the parent method Clear will be called without any additional actions. If the component is Active, then all the nodes and all the DataSet records are being deleted, and DataSet is being blocked with the BeginEdit - EndEdit methods.

 
 

Class TmsCustomDBTreeView - TmsDBTreeView

Properties

  • property TVActive: Boolean;
    Shows the TmsDBTreeView component state.
    Description:
    If the property value is true, then the TmsDBTreeView component is active and you can add/ delete/ edit the nodes. If the property value is false, then the TmsDBTreeView component isn't active, and the calling most of the methods tree editing generates an STVIsntActive error.
    Note:
    The TVActive property is only for read. When the DataSet.Active property changes, the TVActive property changes too. The property value sets in true if:
       - DataSet isn't nil;
       - DataSet is Active;
       - the DataSet fields are found and they are correct for the work of the component.
    The list of fields, needed for the work of the component, look here.
  • property TVBuilding: Boolean;
    Shows if the tree nodes are in the process of being loaded and initialized.
    Description:
    If the property value is true, then data from DataSet are loaded, and the tree is being built.
    Note:
    The TVBuilding property is only for read. It's true before the start of the tree building and it's false after the end of the tree building.
  • property TVEditing: Boolean;
    Shows if the DataSet data are in the process of being updated, when the tree nodes have changed (adding/ deleting/ moving/ editing the node label).
    Description:
    If the property value is true, then DataSet data are being updated.
    Note:
    The TVEditing property is only for read. It's true before the start of the DataSet updating and it's false after the end of the DataSet updating.
  • property DataSetModified: Boolean;
    Shows if the tree nodes are in the process of being updated, when the DataSet have changed.
    Description:
    If the property value is true, then the tree nodes are being updated.
    Note:
    The FDataSetModified property is only for read. It's true before the start of the tree nodes updating and it's false after the end of the tree nodes updating.
  • property DataSource: TDataSource;
    TDataSource provides an interface between a dataset component and tree view control.

Methods

  • constructor Create(AOwner: TComponent); override;
    Creates and initializes a new TmsDBTreeView object.
  • destructor Destroy; override;
    Frees the memory associated with the TmsDBTreeView object.
  • procedure BeginEdit;
    Increases the number of the blockings.
    Description:
    Use the BeginEdit method to increase the number of the blockings. If the first blocking is set, then the flag TVEditing is true, the bookmark to the current record is remembered, the updating in the components is disabled.
  • procedure EndEdit;
    Decreases the number of the blockings.
    Description:
    Use the EndEdit method to decrease the number of the blockings. If all the blockings are removed, then the flag TVEditing is false, the cursor is set to the remembered record, the updating in the components is enabled.
  • procedure DeleteNode(ANode: TmsBaseTreeNode = nil); override;
    Deletes a node.
    Description:
    Use the DeleteNode method to delete the node. The operation is possible if the component is active (TVActive=true). During the DeleteNode operation the DataSet is being blocked with the BeginEdit - EndEdit methods.
  • procedure PasteNode(ATargetNode: TmsBaseTreeNode = nil); override;
    Pastes a node.
    Description:
    Use the PasteNode method to copy the node. The operation is possible if the component is active (TVActive=true). During the PasteNode operation the DataSet is being blocked with the BeginEdit - EndEdit methods.
  • procedure LoadFromFile(const FileName: string); override;
    Reads the file specified in FileName and loads the data into the tree view.
    Description:
    Use the LoadFromFile method to retrieve tree view nodes from a file and add them to the tree view. If the TmsDBTreeView component isn't active (TVActive = false), then the data won't be loaded, and the STVIsntActive error will be generated. If the component is active, then the data will be loaded and the DataSet will be blocked with the BeginEdit - EndEdit methods.
  • procedure LoadFromStream(Stream: TStream); override;
    Reads tree view data from a stream and stores the contents in the tree view.
    Description:
    Use LoadFromStream to read the nodes of the tree view from the specified stream. If the TmsDBTreeView component isn't active (TVActive = false), then the data won't be loaded, and the STVIsntActive error will be generated. If the component is active, then the data will be loaded and the DataSet will be blocked with the BeginEdit - EndEdit methods.

 
 

The list of the fields, required for the work with the component:

  Field Type Delphi Type
  ID counter ftAutoInc
  ParentID integer ftInteger
  Expanded logical ftBoolean
  Text string ftString or ftWideString


 

Copyright © mSunSoftware. 2006. All rights reserved.