Also talk about TTREEVIEW, TLISTVIEW usage

zhaozj2021-02-16  51

During this time, since a technical issue is to be solved, I will run this to check the information on the Internet all day. Since I mainly use Delphi as a development tool, I also read the Delphi classification documentation of the 9CBS Document Center, and harvest well. In that hundreds of documents, there are several documentation theories and TtreeView and TListView in the VCL library. When talking about TreeView, it is mainly how to build trees and data structures; when ListView, it mainly tells the support file drag. Today, I want to take TTREEVIEW as an example, tell another aspect of these two VCL classes - TreeView or ListView's Item Data properties. Because I have seen the documentation, it is basically unspecified, most of them use array or string lists to save data in the tree node - such as the identification number of some data in an array. In fact, it is not a good solution to the array or tstrings to save, everyone knows that there is a Data property of Treenode and ListItem, which is flexible to use this pointer, which is much better than the array and tstrings. Of course, this is just a small skill. If you know the skills of this technology, please don't laugh; often take a friend of the node data in an array or tstrings, you can take a look at ^ o ^

I will explain to a more common sector tree - we build a department tree and display the name of the department in the tree node, and when the user selects the node in the tree, the corresponding data (such as a list) is displayed. We know, because the department name is likely to be repeated, so the department tree cannot be positioned in the department name, and can only be positioned in departmental code, so we have to save the department code in the tree node.

First, the declaration of a structure to save your node data:

Type TunitNodeInfo = Record

UNITCODE: STRING;

转载请注明原文地址:https://www.9cbs.com/read-25196.html

New Post(0)