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
Titre:
Problem Reading Treeview.Node.Tag
Divers
Thread ID:
01336112
Message ID:
01336112
Vues:
67
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?
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform