Treeview

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • amruta

    #1

    Treeview

    Dim objNode As MSComctlLib.Nod e
    TreeView1.Image List = ImageList1 'Assign the image list to TreeView
    Set objNode = TreeView1.Nodes .Add() 'Create the Server Node

    I need to conver the above VB 6.0 code to VB .NET.

    Set objNode = TreeView1.Nodes .Add() changes to
    objNode = TreeView1.Nodes .Add()

    but iam getting an error that add has wrong number of arguments and if i add
    some argument it says "Error 91: object reference not set to an instance of
    an object"

    PLEASE HELP.
    thank you
  • Ken Tucker [MVP]

    #2
    Re: Treeview

    Hi,


    Treeview.Nodes. Add does not return a treenode. Try something like
    this instead.

    Dim objNode as Treenode

    objNode = new TreeNode("New Nodes Text")

    treeview1.nodes .add(objNode)

    Ken
    -------------------------
    "amruta" <amruta@discuss ions.microsoft. com> wrote in message
    news:31E0A914-E93C-4D7A-AA7D-9CE9D2BD37C0@mi crosoft.com...
    Dim objNode As MSComctlLib.Nod e
    TreeView1.Image List = ImageList1 'Assign the image list to TreeView
    Set objNode = TreeView1.Nodes .Add() 'Create the Server Node

    I need to conver the above VB 6.0 code to VB .NET.

    Set objNode = TreeView1.Nodes .Add() changes to
    objNode = TreeView1.Nodes .Add()

    but iam getting an error that add has wrong number of arguments and if i add
    some argument it says "Error 91: object reference not set to an instance of
    an object"

    PLEASE HELP.
    thank you


    Comment

    • Sarika

      #3
      RE: Treeview

      Amruta,

      I assume that you are trying to convert the VB 6.0 code to VB.NET by yourself.

      If you want you can use the Upgrade wizard that will automatically migrate
      the VB 6.0 code to VB.NET. However one limitation of doing it this way is
      that you will be stuck with the old ActiveX Treeview control. Since you are
      upgrading your application you might want to take advantage of the
      Windows.Forms.C ontrol.

      I would suggest that you use the upgrade wizard and then manually migrate
      the treeview if you feel like.

      In VB.NET syntax the code for what you are trying to do would be
      ///
      Dim objNode as TreeNode
      objNode = Treeview1.Nodes .Add("")
      \\\

      HTH

      Comment

      • amruta

        #4
        Re: Treeview

        Both ur replies helped.

        I had few more questions...

        how to I get a image for the node in the treeview.

        how do i expand and collapse nodes in the treeview.

        Thank you very much for your help.





        "Ken Tucker [MVP]" wrote:
        [color=blue]
        > Hi,
        >
        >
        > Treeview.Nodes. Add does not return a treenode. Try something like
        > this instead.
        >
        > Dim objNode as Treenode
        >
        > objNode = new TreeNode("New Nodes Text")
        >
        > treeview1.nodes .add(objNode)
        >
        > Ken
        > -------------------------
        > "amruta" <amruta@discuss ions.microsoft. com> wrote in message
        > news:31E0A914-E93C-4D7A-AA7D-9CE9D2BD37C0@mi crosoft.com...
        > Dim objNode As MSComctlLib.Nod e
        > TreeView1.Image List = ImageList1 'Assign the image list to TreeView
        > Set objNode = TreeView1.Nodes .Add() 'Create the Server Node
        >
        > I need to conver the above VB 6.0 code to VB .NET.
        >
        > Set objNode = TreeView1.Nodes .Add() changes to
        > objNode = TreeView1.Nodes .Add()
        >
        > but iam getting an error that add has wrong number of arguments and if i add
        > some argument it says "Error 91: object reference not set to an instance of
        > an object"
        >
        > PLEASE HELP.
        > thank you
        >
        >
        >[/color]

        Comment

        • Sarika

          #5
          Re: Treeview

          Check out the Treeview documentatio
          http://msdn.microsoft.com/library/de...oloverview.asp

          HTH

          Comment

          • amruta

            #6
            Re: Treeview

            HI,
            how do I set a node as parent node?

            objnode.parent = .....

            it says parent is readonly ...


            also not able to expand and collapse.

            what is equivalent to KEY?

            "Sarika" wrote:
            [color=blue]
            > Check out the Treeview documentation
            > http://msdn.microsoft.com/library/de...oloverview.asp
            >
            > HTH
            >[/color]

            Comment

            • Sarika

              #7
              Re: Treeview

              There is no equivalent to the Key property of the older treeview. You could
              use the Tag property instead.

              Yes that property is a readonly property. A node becomes a parent node if
              you add nodes to it.

              I would suggest that you read the documentation to understand the concepts.

              HTH

              Comment

              Working...