By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,510 Members | 1,815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,510 IT Pros & Developers. It's quick & easy.

Treeview

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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" <am****@discussions.microsoft.com> wrote in message
news:31**********************************@microsof t.com...
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
Nov 21 '05 #2

P: n/a
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
Nov 21 '05 #3

P: n/a
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:
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" <am****@discussions.microsoft.com> wrote in message
news:31**********************************@microsof t.com...
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

Nov 21 '05 #4

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

HTH

Nov 21 '05 #5

P: n/a
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:
Check out the Treeview documentation
http://msdn.microsoft.com/library/de...oloverview.asp

HTH

Nov 21 '05 #6

P: n/a
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
Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.