Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7998865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:20:11+00:00 2026-06-04T15:20:11+00:00

I use TreeView in my C# project (Windows Forms) and I have a problem

  • 0

I use TreeView in my C# project (Windows Forms) and I have a problem (obviously :P). I fill my TreeView like this:

void RefreshTreeView()
{
    treeView1.Nodes.Clear();
    for (int i = 0 ; i < categories.Count ; ++i)
    {
        treeView1.Nodes.Add(categories[i].name);
        for (int j = 0 ; j < categories[i].questions.Count ; ++j)
        {
            treeView1.Nodes[i].Nodes.Add("Pytanie nr " + categories[i].questions[j].number.ToString()
                + " za " + categories[i].questions[j].points.ToString() + " pkt. ["
                + (categories[i].questions[j].used ? "Przeczytane" : "Nieprzeczytane") + "]");
            treeView1.Nodes[i].Tag = categories[i].questions[j];   // A
        }
    }
}

In line marked “A” above I attach a Question object to Node’s Tag. And it seems to work as later on in the program I can retrieve my Question object like this:

((Question)treeView1.Nodes[0].Tag).number

But I want to get the currently selected Node’s Tag. Which I try to do like this:
((Question)treeView1.SelectedNode.Tag).number
But it doesn’t work (Tag is null). What am I doing wrong? And how to get the currently selected Node’s Tag?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:20:12+00:00Added an answer on June 4, 2026 at 3:20 pm

    treeView1.Nodes[i].Tag is the tag of the parent node.

    You probably want to set the tag of the child node, which is treeView1.Nodes[i].Node[j].Tag

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i use a treeview to display files and folders like Windows Explorer. it has
i use a treeView and a listView to display file and folders like Windows
I use Win forms treeview class. I need to have possibililty to navigate to
I have a TreeView in my Windows Form user interface. I want to fill
I use asp.net 4 and c#. I have a TreeView and I would like
I'm working with application, which use TreeView. I want some nodes have checkBoxes, but
I would like to use standard icons in treeview but I am not sure
I have a hierarchical treeview in WPF. I use http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/ for eventbinding with the
i use such treeview http://docs.jquery.com/Plugins/Treeview/treeview , it saves perfect opened nodes when i click
Inspired by this post , I'm trying to use a TreeView inside the AutoCompleteBox's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.