Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共2 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:输出TreeView问题

1楼
HJG_HB950207 发表于:2024/12/26 7:43:00
以下为输出代码:

Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim doc As New PrintDoc '定义一个报表
For Each nd As WinForm.TreeNode In trv.AllNodes
    Dim rt As New prt.RenderText '定义一个文本对象
    rt.Text = "".PadLeft(nd.Level * 4) & nd.Text
    
    doc.Body.Children.Add(rt)  
Next
doc.Preview()  

以上输出无各层关系的连接符号“..."":"

请教:如何输出时将各层的连接符号也含其中》
2楼
有点蓝 发表于:2024/12/26 13:44:00
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim doc As New PrintDoc '定义一个报表
For Each nd As WinForm.TreeNode In trv.AllNodes
    Dim rt As New prt.RenderText '定义一个文本对象
    If nd.Level = 0 Then
        rt.Text = nd.Text
    Else
        Dim s As String = ""
        Dim ad As WinForm.TreeNode = nd.ParentNode
        Dim pd As WinForm.TreeNode
        If ad.ParentNode IsNot Nothing Then
            s = "".PadLeft(6)
            pd = ad.ParentNode
        End If 
        Do While pd IsNot Nothing
            If pd.Level > 0 Then
                If pd.Nodes.Count - 1 = ad.Index Then
                    s = "".PadLeft(6) & s
                Else
                    s = "".PadLeft(6) & ":" & s
                End If
            ElseIf trv.Nodes.Count - 1 > pd.Index AndAlso s.StartsWith(":") = False Then
                    s = ":" & s
            End If 
            ad = pd
            pd = pd.ParentNode
        Loop
        rt.Text = s & ":" & "".PadLeft(4, ".") & nd.Text
    End If
    doc.Body.Children.Add(rt) 
Next
doc.Preview() 
共2 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .01904 s, 2 queries.