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 8099335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:22:36+00:00 2026-06-05T22:22:36+00:00

In the Winform, i have a UserControl TreeView and It loads real time data

  • 0

In the Winform, i have a UserControl TreeView and It loads real time data from XML file. The XML files loaded successfully in the treeView.

I want to generate TreeView with Different images for different sets of data. This link explains to generate treeview for specific array of data. [http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.imagelist][1]

How can I add different images for each parent and child nodes, in the XML, I want to add different images for Global Files Section and for Data. Please explain to me with some snippet.

<Global>
 <Files name="Bit_RunvsDepth" >
      <Section name="Linguini">
        <Data>measured depth</Data>
      </Section>
      <Section name="Process">
        <Data>Tree</Data>
        <Section name="Arguments">
          <Data>None</Data>
        </Section>
        <Section name="Extras">
          <Data>0.01</Data>
          <Data>Foodg</Data>
        </Section>
      </Section>
      <Section name="Color">
        <Data>0.0</Data>
      </Section>
      <Section name="MinScale">
        <Data>0</Data>
      </Section>
      <Section name="MaxScale">
        <Data>1000</Data>
      </Section>
    </Files>
</Global>
  • 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-05T22:22:38+00:00Added an answer on June 5, 2026 at 10:22 pm

    TreeNode class is not sealed, so you can build a hierarhy of custom node types.

         abstract class CustomTreeDataNode : TreeNode
         {
            public CustomTreeDataNode()
            {
            }   
    
            protected void ReadChildNodes<T>(XmlNode parent, string childNodeName)  
                 where T: CustomTreeDataNode, new()
           {
                  foreach(XmlNode node in parent.SelectNodes(childNodeName))
                  {
                      T item = new T();
                      item.Fill(node);
                      Nodes.Add(item);
                  }
           }
    
            public void Fill(XmlNode node)
            {
                 Nodes.Clear();
                 InitProperties(node);
            }
    
            protected abstract void InitProperties(XmlNode node);
    
         }
    
         class RootNode : CustomTreeDataNode
         {
            protected override void InitProperties(XmlNode source)
            {
                Text = "Root";
                ItemIndex = ROOT_ITEMINDEX;
                SelectedIndex = ROOT_SELECTEDINDEX;
                ReadChildNodes<FileNode>(source, "Files"));
            }
         }
    
         class FileNode : CustomTreeDataNode
         {
            protected override void InitProperties(XmlNode source)
            {
                Text = source["name"];
                ItemIndex = FILE_ITEMINDEX;
                SelectedIndex = FILE_SELECTEDINDEX;
                ReadChildNodes<SectionNode>(source, "Section"));
            }
         }  
    
         class SectionNode : CustomTreeDataNode
         {
            protected override void InitProperties(XmlNode source)
            {
                Text = source["name"];
                ItemIndex = SECTION_ITEMINDEX;
                SelectedIndex = SECTION_SELECTEDINDEX;
                ReadChildNodes<DataNode>(source, "Data"));
            }
         }  
    
         class DataNode : CustomTreeDataNode
         {
            protected override void InitProperties(XmlNode source)
            {
                Text = source.Text;
                ItemIndex = DATA_ITEMINDEX;
                SelectedIndex = DATA_SELECTEDINDEX;
            }
         }  
    
         ...
         RootNode root = new RootNode();
         root.Fill(rootXmlNode); 
    
         treeView1.Nodes.Add(root);
    

    To draw images TreeView relies on ImageView component. This link explains how to load images programmatically

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

Sidebar

Related Questions

I have a winform with preloaded DataGridView over it...I want to remove rows from
I have a winform (in C#) that encrypt and decrypt a file... it's OK,
I have UserControl that holds Infragistics Graph control. On the TreeView sub node's right
I have a WPF UserControl nested inside an ElementHost in a WinForm UserControl intended
I have a User Control that has some WinForm Controls inside. I want to
I have a winform usercontrol with several items (textboxes, buttons,...). Now I am confronted
I have a WinForm UserControl inside a WPF window and the WPF code is
I have a winform with a wpf usercontrol on it (ElementHost1). The usercontrol contains
I have a WinForm that uses an ElementHost to display a WPF UserControl. Once
I have a WinForm App(.Net 3.5) that we use in house for data entry...ish,

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.