Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem Reading Treeview.Node.Tag
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01336112
Message ID:
01336188
Views:
17
I found the problem. Thanks everyone!



>>>In my routine to load a treeview, I place a code on the tag which is the level and the node type code:
>>>
>>>
>>>private void LoadTree()
>>>{
>>>    TreeNode oNode;
>>>
>>>    oNode = treeView1.Nodes.Add("Customers");
>>>    oNode.Tag = "0.customers";
>>>
>>>    oNode = treeView1.Nodes.Add("Accounts");
>>>    oNode.Tag = "0.accounts";
>>>    oNode.Expand();
>>>
>>>    foreach (csItem oItem in csAppStartup.oItems.colItems)
>>>    {
>>>        oNode.Nodes.Add(oItem.sCaption);
>>>        oNode.Tag = "1." + oItem.sItemCode;
>>>    }
>>>
>>>}
>>>
>>>
>>>
>>>Then in the Mouse up I want to read the tag of the selected node to see which item the user right-clicked on:
>>>
>>>
>>>private void treeView1_MouseUp(object sender, MouseEventArgs e)
>>>{
>>>
>>>    if(e.Button == MouseButtons.Right)
>>>    {
>>>        TreeNode oNode = treeView1.SelectedNode;
>>>        string sNodeInfo = oNode.Tag.ToString();
>>>
>>>    }
>>>}
>>>
>>>
>>>On the last line I'm getting "Object reference not set to an instance of an object.".
>>>
>>>Anyone see what's wrong?
>>
>>Maybe null values in some sItemCode?
>
>When the LoadTree method finished, all Node Tags were populated with valid string values. When MouseUp executes, the Tag property for each node is null.
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform