-
Oct 25th, 2012, 01:02 PM
#1
Thread Starter
Member
Access object in treeview tag
Good morning Forum,
I have come across a problem trying to access an object I assigned to one of my nodes in a treeview. I used the following code to assign the object.
Code:
NodeInfo.Type = "Item"
NodeInfo.Index = 100
BidItemNode.Tag = NodeInfo
NodeInfo is a Structure
Code:
Structure tvTag
Public Type As String
Public Index As Integer
End Structure
How do I access the data now stored in the tag property of the treeview? I have tried the following with no luck
Code:
dim rNodeInfo as tvTag = NodeInfo.Tag
-
Oct 25th, 2012, 01:51 PM
#2
Re: Access object in treeview tag
what does that mean? Did you accidentally fire off a nuclear warhead or something? Did you get something you didn't expect or did you not get something that you should have?
Since it's a structure type, it's also being treated as a value type... so depending on how you loaded it in the first place could also have some impact. Also... don't forget that the .Tag member is a nOBJECT type... so anything you put in there needs to be converted back to the correct type when extracting it. Since you didn't get a compile warning or error on that last line of code... that tells me you have Option Strict and possibly Option Explicit turned off.
-tg
-
Oct 25th, 2012, 04:13 PM
#3
Thread Starter
Member
Re: Access object in treeview tag
what does that mean? Did you accidentally fire off a nuclear warhead or something? Did you get something you didn't expect or did you not get something that you should have?
haha, no just a unwanted error!
We'll I tried:
Code:
Dim rNodeinfo As tvTag = CType(NodeInfo.Tag, tvTag)
and got the Error: Specified cast not valid
-
Oct 25th, 2012, 04:43 PM
#4
Re: Access object in treeview tag
It's all in the declarations ....
vb.net Code:
Dim tv As New tvTag ' see what I did there?
tv.Type = "a"
tv.Index = 1
TreeView1.Nodes(0).Tag = tv
Dim tv1 As New tvTag
tv1 = TreeView1.Nodes(0).Tag
Label1.Text = tv1.Type & tv.Index.ToString
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Oct 25th, 2012, 05:43 PM
#5
Thread Starter
Member
[RESOVLED]Re: Access object in treeview tag
I found the problem. I wasn't paying attention to one of the nodes and forgot to set the class to one of them. It still had its string type tag.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|