Treeview

G

Guest

Dim objNode As MSComctlLib.Node
TreeView1.ImageList = 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
 
K

Ken Tucker [MVP]

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
-------------------------
Dim objNode As MSComctlLib.Node
TreeView1.ImageList = 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
 
G

Guest

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.Control.

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
 
G

Guest

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.
 
G

Guest

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?
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top