Treeview Control

G

Guest

Is it me or has the VB.NET Treeview control gone back to the darkages.

I am trying to update a VB6 programme that uses the treeview control a lot- there are 4 treeview controls which are constantly being altered by user input.
On upgrading the treeview errors are too numerous to list all of them.

What has happened to 'Treeview1.nodes.add (ParentNode, Relation, NodeKey, Text)'? and Treeview1.nodes(NodeKey)

Why is there no Node.Key?

My VB6 programme relies on the Node.Key to access a node and alter texts and keep track of what the children of a parent node are.


Can someone enlighten me please.
 
A

Armin Zingler

JamesT said:
Is it me or has the VB.NET Treeview control gone back to the
darkages.

I am trying to update a VB6 programme that uses the treeview control
a lot- there are 4 treeview controls which are constantly being
altered by user input. On upgrading the treeview errors are too
numerous to list all of them.

What has happened to 'Treeview1.nodes.add (ParentNode, Relation,
NodeKey, Text)'? and Treeview1.nodes(NodeKey)

Why is there no Node.Key?
Hmmmm....

My VB6 programme relies on the Node.Key to access a node and alter
texts and keep track of what the children of a parent node are.

Additionally add the nodes to a Hashtable. You can access them by the key.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
R

Robin Tucker

Its silly, but you can maintain your own hash to keys for the tree view.
ie. whenever you add a node, you add a hash to the item into a hashtable -
then, fetching the node from its key is just a case of asking the hashtable
for it. As to why this is the case, I have no idea ;)


JamesT said:
Is it me or has the VB.NET Treeview control gone back to the darkages.

I am trying to update a VB6 programme that uses the treeview control a
lot- there are 4 treeview controls which are constantly being altered by
user input.
On upgrading the treeview errors are too numerous to list all of them.

What has happened to 'Treeview1.nodes.add (ParentNode, Relation, NodeKey,
Text)'? and Treeview1.nodes(NodeKey)
Why is there no Node.Key?

My VB6 programme relies on the Node.Key to access a node and alter texts
and keep track of what the children of a parent node are.
 
P

Peter Huang

Hi Jim,

First of all, I would like to confirm my understanding of your issue.

From your description, I understand that you wants to use key property in
VB.NET treeview just as the vb6 treeview do.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

The version of the TreeView control that is included with Visual Studio
..NET has no equivalent Key property so far.
Here is an KB article you may take a look.
HOW TO: Create a Key Property for a TreeView Node in Visual Basic .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;311318

Also as Robin said, you can add all the nodes to a 'Hashtable' by using a
unique name as key.
Then you can access the nodes by key easily.

Please apply my suggestion above and let me know if it helps resolve your
problem.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Peter

Sorry for delay in replying

What you suggest does seem to cure the problem of no KEY, but I still have a problem of adding a child node to a parent node easily
I drag a listviewItem to the TreeView, over either a child node or the parent node, and then add the item, as a child, to the parent, checking first to see if the node already exists and then changing the text to have a count at the end. Also being able to drag a child from one parent to another(cruel I know

example:(in plainish VB6/English
(Drag a ListViewItem on to TreeView
pNode = GetParentNode(of node where Item dropped) ' get parent node if child, or node if paren
' the same item can exist in different parents with th
' parent key being added to the child ke
if NodeExist(ListViewItem.Key) then 'returns boolean if node already present within the parent nod
nodekey=ListViewItem.key ' ensures nodekey = listitemke
NCount= right(Node(NodeKey).text,3) ' update counter at end of tex
Node(NodeKey).text=left(node(NodeKey).text,len(node(NodeKey).text)-3 & format(NCount,"000") ' change tex
els

dim nNode as new node ' new nod
nNode.text= ListviewItem( & ":001" (Or TreeviewItem text) ' Set tex
nNode.key=listViewItem.key (or TreeView.Node.key) ' set Ke
pNode.nodes.add nnode ' add nod
end i

The above works well if KEYS are used but I seem to have a mental block in VB.NET.
you can see why I have a dependence on KEYS

I see that in VS 2005 the KEY is back. perhaps the ADD(parent node,relation,key,text) will reappear as well. Microsoft please note!!!

I may decide to switch to VS 2005 to rewrite my programme, it will take some time as there are a lot of new features I want to add to it, and hope that a better version than the March Preview becomes available soon

James
 
P

Peter Huang

Hi James,

Yes, this is a limitation in the treeview control shipped with VS.NET 2003
so far. And in the next the feature(key) should be back, but I can not
guarantee the behavior before the VS.NET 2005 is released officially.

So far we can only to workaround the problem as I said in my last post.

If you still have any concern on this issue, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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