Treeview dynamic generation method!

Source: Internet
Author: User

''' <Summary>
''' Load the root node

''' </Summary>
''' <Remarks> </remarks>
Private sub loadtreeview ()

Private SQL as string 'SQL
Dim ds as dataset record set

Dim dT as datatable
Dim I as integer
SQL = "select * From usysforms"
DS = mnsqlhelper. executedataset (SQL)
Dt = Ds. Tables (0)
For I = 0 to DT. Rows. Count-1
If DT. Rows (I). Item ("frm_id"). Trim = "0" then
Dim tnode as new treenode

Tnode. Tag = DT. Rows (I). Item ("frm_id"). Trim
Tnode. Text = DT. Rows (I). Item ("frm_name_c"). Trim
'Zookeeper has expired
Tnode. imagekey = DT. Rows (I). Item ("icon_name"). Trim

Tnode. selectedimagekey = tnode. imagekey
'Zookeeper has been appended with zookeeper
Me. ctrvmenu. nodes. Add (tnode)

Loadsubtree (DT, tnode, 0)
End if
Next

Ctrvmenu. nodes (0). Expand ()

End sub

''' <Summary>
''' Load subnodes

''' </Summary>
''' <Param name = "dttable"> memory set </param>
''' <Param name = "tnode"> root node </param>
''' <Param name = "frmid"> frm_id </param>
''' <Remarks> </remarks>
Private sub loadsubtree (byval dttable as datatable, byval tnode as treenode, byval frmid as string)
Dim I as integer
For I = 0 to dttable. Rows. Count-1
If dttable. Rows (I). Item ("frm_id"). Trim <> "0" then
If dttable. Rows (I). Item ("root_bun"). Trim <> "1" then
If dttable. Rows (I). Item ("frm_id_last"). Trim = frmid then
Dim snode as new treenode

Snode. Tag = dttable. Rows (I). Item ("frm_id"). Trim
Snode. Text = dttable. Rows (I). Item ("frm_name_c"). Trim
Snode. imagekey = dttable. Rows (I). Item ("icon_name"). Trim
Snode. selectedimagekey = snode. imagekey

Tnode. nodes. Add (snode)

Loadsubtree (dttable, snode, dttable. Rows (I). Item ("frm_id"). Trim)
Snode = nothing
End if
End if
End if

Next

End sub

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.