Programming C++Builder How to Use TTreeview and TListView in C Builder and Delphi

How to use Tree view?

A tree view (TTreeView) displays items in an indented outline. The control provides buttons that allow nodes to be expanded and collapsed. You can include icons with items' text labels and display different icons to indicate whether a node is expanded or collapsed. You can also include graphics, such as check boxes, that reflect state information about the items.

  • Indent sets the number of pixels horizontally separating items from their parents.
  • ShowButtons enables the display of '+' and '-'¬†buttons to indicate whether an item can be expanded.
  • ShowLines enables display of connecting lines to show hierarchical relationships (VCL only).
  • ShowRoot determines whether lines connecting the top-level items are displayed (VCL only).

To add items to a tree view control at design time, double-click on the control to display the TreeView Items editor. The items you add become the value of the Items property. You can change the items at runtime by using the methods of the Items property, which is an object of type TTreeNodes. TTreeNodes has methods for adding, deleting, and navigating the items in the tree view.

Tree views can display columns and subitems similar to list views in vsReport mode.

How to use List views?

List views, created using TListView, display lists in various formats. Use the ViewStyle property to choose the kind of list you want:

  • vsIcon and vsSmallIcon display each item as an icon with a label. Users can drag items within the list view window (VCL only).
  • vsList displays items as labeled icons that cannot be dragged.
  • vsReport displays items on separate lines with information arranged in columns. The leftmost column contains a small icon and label, and subsequent columns contain subitems specified by the application. Use the ShowColumnHeaders property to display headers for the columns.

TTreeView and TListView both are the most important components in C Builder or Delphi. We can use these two components to do handle many categories or datas in our program. Also, these two components both are the difficult one to be handled. I will give out some examples of using Tree View and List View later when I have time. Hope you could be back.

Add comment

Security code

Programming - C++Builder