Click here to Skip to main content
15,038,345 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The file is saved as resource. How to obtain that name of the file into tree View?

What I have tried:

C#
private void Form1_Load(object sender, EventArgs e)
        {
            treeView1.ImageList.Images.Add(Properties.Resources.ResourceManager.GetString("database.png"));
            
        }

Build says cannot convert from string to System.Drawing.Icon.
Posted
Updated 24-Jul-20 21:31pm
v3
Comments
Gerry Schmitz 23-Jul-20 9:29am
   
..GetString() returns a string; ..Images.Add() does NOT (just) take a string; it takes an icon or image, at least.

1 solution

Try following:
C#
treeView1.ImageList.Images.Add("myImage", Properties.Resources.IconNameInResource);

BTW, will suggest following read - from a defined ImageList: Redirect Notice[^]
   
Comments
Member 12712527 24-Jul-20 5:00am
   
After Properties.Resurces no Name of the .png file as mentioned in the resource is comming...
Member 12712527 24-Jul-20 5:02am
   
After Resource. onle culture,equals, reference equal and resource manager is comming.
Sandeep Mewara 24-Jul-20 5:16am
   
You need to add icon to your resource file.
Sandeep Mewara 24-Jul-20 5:23am
   
Some references of it can be picked from here on how to add image to resource: https://www.technical-recipes.com/2017/how-to-use-resource-files-in-your-csharp-project/
Sandeep Mewara 25-Jul-20 3:30am
   
That did not help?

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