473,320 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How do I associate external data with tree nodes?

Well... I posted this question once, but it's gone. I guess I needed to post my introduction first. I am still learning as I go, so bear with me.
The language is VB.Net

1) I am making a program where a user will click on a specific tree node thus creating textbox objects. The textboxes are hard programed into the .exe. I need to call their creation and set properties when different nodes are clicked. I need to be able to save this creation data in an external, user customizable file saying something like:
'node address/path'( 'textbox1 label' DATA,'textbox2 label' DATA,'textbox3 label' DATA, ...)
'a/b/c/node1'( 'IP Address' ipaddress,'Subnet','Port' )
'a/b/c/node2'( 'Protocol' protocol )
Any help with a code protocol would help too.
An Access Database could be used I guess. This tree is large and deep. If you have taken Cisco CCNA, this tree will contain all commands for a Cisco device.
How do I accomplish this?

2) How do I save the tree data and keep associations with the nodes?

Any help would be greatly appreciated. Any (human) names given in posts will be included in my program's sources list.
Oct 29 '07 #1
14 1836
This uses my example in the previous post with IP Address.
Another thing I should add is when a user clicks on a tree node, the following happens:
1) I click on node "configure\terminal_\interface\s0/0"
2) The program puts the following into a textbox ( "_" = enter):
configure terminal
interface s0/0
3) The following textboxes will be created:
"IP Address"________, "Subnet Mask"_________
4) When send is clicked, the following will be sent to the Cisco device:
configure terminal
interface s0/0
ipaddress 192.168.0.1 255.255.255.0

I hope this makes some sense.
Oct 29 '07 #2
Plater
7,872 Expert 4TB
So when you click a node, some textboxes will show up and be filled with data that is specific to the treenode that was clicked?
There is a property on TreeNodes (as well as on others) called .Tag that will take an Object (so pretty much anything can be assigned to it) where you can either store what would pop up into those textboxes, or store some sort of unique identifier you could use to reference some data stored in a table in a database to get your text to populate into the textboxes.
Oct 30 '07 #3
So when you click a node, some textboxes will show up and be filled with data that is specific to the treenode that was clicked?
Not quite. When you click a node, it creates the boxes then a user will fill them in. It will put the node.fullpath data into a permanent (editor) text box.
I have used the .tag before, so I guess it would work. But... would saving the tree into an xml document be able to save the .tag data? I have not attempted an xml save yet, so I don't know what options I have. I am still writing the code to get the commands from the cisco device in order to build the actual tree. I guess I should start working on xml then, right?

Here is the data I want to save:
node.fullpath
node.text
node.(mouse hover message/text if option is available)
node.tag 'I will use this for textbox creation data
Oct 30 '07 #4
Plater
7,872 Expert 4TB
Hmm, I don't know if the .Tag will go to the XML file naturally or if you would have to be sneaky about it.
I guess I would suggest getting all your CISCO commands into the correct heirarchy first, then figure out where to go from there.
Oct 30 '07 #5
It's hard because I need to know how to handle the data correctly to save into the database. The data is being received in the order (pseudo):
root THEN
root1.children THEN
root1.child1.children THEN
root1.child1.child1.children THEN
(if no more children) -> (step back one level and do the next child)
root1.child1.child2.children
This goes on and on until it finishes the last node in the root. Can Access do a hierarchical database without creating a table for each level?
Oct 30 '07 #6
Plater
7,872 Expert 4TB
There was a post in here about a way to do just that with a datatable.


You could have a table with columns like:
[ObjectName] | [ParentObjectName] | [Data]
----------------------------------------------------------------

Then you could do like this
[ObjectName] | [ParentObjectName] | [Data]
----------------------------------------------------------------
"root" | (empty) | (data)
"child1" | "root" | (data)
"child2" | "root" | (data)
"child3" | "child1" | (data)
"child4" | "root" | (data)
(and so on)

there you could see that you would have:
root
child1
child3
child2
child4
Oct 30 '07 #7
I would have to use a full path instead because nodes with a simmilar name to a parent would create havoc. Do you have any idea how big the file might be? I'm thinking it should have 200+ entries maybe 500KB.

I'll try this and get back to you in a day or so.
Oct 30 '07 #8
Plater
7,872 Expert 4TB
Don't think inside the box on this, consider it this way then:

ObjectID | ParentID | ObjectName | Data
-----------------------------------------------------------
1 | (empty) | "root" | (data)
2 | 1 | "Child1" | (data)
3 | 2 | "Child3" | (data)
4 | 1 | "Child2" | (data)
(etc)
Oct 30 '07 #9
Yes okay. Sorry. I didn't get any sleep and was pretty dead yesterday. That seems to make a lot more sense than puting the path. I can probably take out the parent name reference.
Oct 31 '07 #10
How do I save an entry to the database and what is the SQL statement?
Right now I have the script adding commands into the tree. When it is done, I can save it by doing the following:
treeview.expand all nodes
dim i as integer = 0
dim n as treenode()
while(i<treeview.visiblecount)
n = treeview.nodes.find(i.tostring, true)
treeview.selectednode = n(0)
'***** GET EACH PROPERTY OF NODE AND SAVE TO DATABASE *****'
'selectednode.text
'selectednode.name
'if (has parent)
'selectednode.parent.name
'end if
'selectednode.tooltiptext
'selectednode.tag
'*****END SAVING*****'
i = i + 1
end while
Nov 6 '07 #11
Plater
7,872 Expert 4TB
Well I made up the table in my sql server and had it generate an insert statement:
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [myTestTables].[dbo].[TreeNodes]
  2.            ([ObjectID]
  3.            ,[ParentID]
  4.            ,[ObjectName]
  5.            ,[Data])
  6.      VALUES
  7.            (<ObjectID, bigint,>
  8.            ,<ParentID, bigint,>
  9.            ,<ObjectName, varchar(50),>
  10.            ,<Data, varchar(100),>)
  11.  
Now you might need to do more work on this, since you wanted to go with the ID and not names.
You will need to add parents before children, and you will need to know their ObjectID (if using my example) to use it as the ParentID of the children.
Nov 6 '07 #12
So bigint, etc. are my data variables? Thanks!
I'll explain a little more since I tend to do really weird things. All of my data is in string format in the database. When the nodes are created:
Expand|Select|Wrap|Line Numbers
  1. NewNode.name = ("ObjectID") 'as string
  2. NewNode.text = ("ObjectName") 'ObjectName is a command as string
  3. NewNode.Parent.name = ("ParentID") 'as string
When nodes are loaded from the database, I load from a query that sorts by ParentID first, ObjectName second. When loading, it finds and selects the parent node with the ObjectID that = the NewNode's ParentID record, then adds that node to the parent node.
Code has root and child paths
Expand|Select|Wrap|Line Numbers
  1. treeview.nodes.clear()
  2. LoadDatabaseArray()
  3. dim i as integer = 0
  4. dim n as treenode() 'treenode array
  5. dim NewNode as treenode
  6. while (DatabaseArray = Something)
  7. n = treeview.find(DatabaseArray(0, i), true) 'Index(0) = ParentID
  8. treeview.selectednode = n(0)
  9. NewNode.text = DatabaseArray(1, i) 'ObjectName
  10. NewNode.name = DatabaseArray(2, i) 'ObjectID
  11. NewNode.tooltiptext = DatabaseArray(3,i) 'ObjectDescription
  12. NewNode.tag = DatabaseArray(4, i) 'ObjectBoxes
  13. treeview.selectednode.nodes.add(NewNode)
  14. i = i+1
  15. end while
Nov 6 '07 #13
Plater
7,872 Expert 4TB
Nono, bigint was my guess at the column type. And that was for psuedocode
An actual string might be more like
Expand|Select|Wrap|Line Numbers
  1. string sqlinsert="";
  2. sqlinsert+= "INSERT INTO [myTestTables].[dbo].[TreeNodes] ( [ObjectID], [ParentID], [ObjectName], [Data] ) ";
  3. sqlinsert+= "     VALUES
  4. sqlinsert+= "(";
  5. sqlinsert+=myObjectId+",";
  6. sqlinsert+=myParentID+",";
  7. sqlinsert+=myObjectName+",";
  8. sqlinsert+=myData;
  9. sqlinsert+=");";
  10.  
Where these are all string containing your data:
myObjectId
myParentID
myObjectName
myData
Nov 6 '07 #14
Oh, okay. Thanks for your help!
Nov 6 '07 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Wolfram Kraus | last post by:
Heyho! I want to associate objects with the nodes of a Tix.Tree. Is this possible, because the following example won't work: --8<-- Cut here ------------------------- import Tix class C:...
4
by: Marek Mänd | last post by:
var criterions = { subconds:{ tree: } } // MUSIC , {condID:17, strrep:'Music', subconds:{ tree:
4
by: Stephan Tobies | last post by:
Hi everyone, I am looking for a good data structure that could be used to represent families of trees with shared sub-trees and copy-on-write semantics. On a very abstract level, I would like...
0
by: Dailan | last post by:
Hi, I create a tree view. Each node has link button associate with it, which includes add, edit, delete buttons. The way I did is for users who have very low capablity of using computer. Now I...
3
by: Tony Burrows | last post by:
I'm building an app which lets users drag and drop classes into a tree, followed by code generation. For this, I need to have (a) a list of all the classes which can be dragged and (b) for each...
4
by: Alexander Adam | last post by:
Hello folks, I got a few question on some basic data structure stuff. Sorry if those questions might sound too easy or such but after googling a lot I didn't find a real answer to all those...
4
by: sharan | last post by:
Hello Friends I have a problem in Data Structure (In C) i want to implement a General tree having three child nodes of each parent node ...please send me any simple Example( code) by which i can...
1
by: jakki | last post by:
hi every one.. i am binding data in a tree view using windows C# .. auctually i finished most of the code.. but i did't know how to proceed further .. i attached the code hear.. as well as...
8
by: =?ISO-8859-1?Q?m=E9choui?= | last post by:
Problem: - You have tree structure (XML-like) that you don't want to create 100% in memory, because it just takes too long (for instance, you need a http request to request the information from...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.