When displaying uncertain tree nodes, most of us use the normal algorithm, to connect to the data multiple times and the database, the algorithm I talked below, just only with the data operation, then use the dynamic array in the tree control Displayed, fast and convenient. I will give you a presentation, and friends who are familiar with the manufacturing industry generally know BOM (product structure). Oracle provides a very convenient function, you can take all the structure of the entire product, such as:
SELECT Level ID, Parent Material Code, Subbrading Code from TB_ Product Structure CONNECT by Prior Property Coding = Parent Material Coding Start with Parent Material Coding = '10C000000'
(Figure 1)
(Figure 1) For the portion of the structure, the ID is the level of the root node, I am based on the regularity of the record, but he does not include information encoding the child material as a root node, all in the construction tree control Pay attention to the information added to the root node, make a specific tree control, as long as the extracted record is paid to the DataSource of the tree control, the tree can be easily displayed, and it is particularly convenient, and it is particularly convenient. Just join the control in the interface. Then give the record set.
Define the information of the node, you can make it easy for the node to populate more information from the database.
Using system;
Using system.collections;
Using system.componentmodel;
Using system.drawing;
Using system.data;
Using system.windows.forms;
Namespace BQ_TREEVIEW
{
///
// / Overloaded tree node, this can be extended to fill more information
/// summary>
Public Class BQ_Treenode: Treenode
{
PRIVATE STRING M_MATID;
Public BQ_TREENODE () {}
///
/// Constructor
/// summary>
/// Node to display text param>
Public BQ_Treenode (String Strtext)
{
Base.text = strText;
}
Public String Matid
{
get
{
Return m_matid;
}
set
{
M_MATID = VALUE;
}
}
}
}