Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem Reading Treeview.Node.Tag
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01336112
Message ID:
01336188
Vues:
18
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform