Subject: question about treeview
Posted By: haiying Post Date: 9/24/2004 4:53:48 AM
Hi ,

I have a question about generating treeview.Here is my code:
Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim aa As New TreeNode(1)
        Dim bb As New TreeNode(2)
        Dim cc As New TreeNode(3)
        Dim dd As New TreeNode(4)
        aa.Nodes.Add(bb)
        aa.Nodes.Add(cc)
        bb.Nodes.Add(dd)
        cc.Nodes.Add(dd)
        TreeView1.Nodes.Add(aa)

    End Sub
    
End Class

the rusult is:
 4
 |
 1-2
   |
   3-4
but i hope the result is :
 1-2-4
   |
   3-4
How should I change my code?

Thanks a lot,

Haiying

Reply By: someshtrivedi Reply Date: 9/25/2004 5:04:05 AM
 hi, Try this       

     Dim aa As New TreeNode(1)
        Dim bb As New TreeNode(2)
        Dim cc As New TreeNode(3)
        Dim dd As New TreeNode(4)

        bb.Nodes.Add(dd)
        cc.Nodes.Add(dd)
        bb.Nodes.Add(cc)
        TreeView1.Nodes.Add(bb)
        TreeView1.Nodes.Add(aa)

good luck
Somesh


Go to topic 19710

Return to index page 764
Return to index page 763
Return to index page 762
Return to index page 761
Return to index page 760
Return to index page 759
Return to index page 758
Return to index page 757
Return to index page 756
Return to index page 755