Click here to Skip to main content
15,921,226 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
How can i apply a specific image for Parent node, sub_child node..etc. For example, I want to assign a different image for countries, country, name, states, state with respect to the XML structure.
I have loaded 5 different images in the image directory. I need some example to add different images to my treeview.


XML
<pre lang="xml">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;countries&gt;
    &lt;country&gt;
        &lt;name&gt;India&lt;/name&gt;
        &lt;states&gt;
            &lt;state&gt;TamilNadu&lt;/state&gt;
            &lt;state&gt;Andhra&lt;/state&gt;
            &lt;state&gt;Kerala&lt;/state&gt;
            &lt;state&gt;Karnataka&lt;/state&gt;
        &lt;/states&gt;
    &lt;/country&gt;
&lt;/countries&gt;</pre>
Posted

1 solution

1. Create an ImageList containing all 5 images.
2. Add the correct image indexes to your XML/datasource.
3. Use the ImageIndexFieldName property to specify which field in your datasource contains the imageindex for each node.

See https://documentation.devexpress.com/#windowsforms/DevExpressXtraTreeListTreeList_ImageIndexFieldNametopic[^] for more information on the ImageIndexFieldName property.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900