ImageSource vs ImageList vs enumerate images in mixin

0
0

Hi Wisej,

we are widely using the ImageSource property for setting the image for various widgets, however, that does not work for TreeView (and TreeNode). These require the ImageList + ImageKey to be set.

Now, we are having an images mixin file, its attributed as embedded resource.

My idea is to create programatically on-the-fly the ImageList a populate it, at application startup, with images from this mixin. Then share this one image list for all tree views in project. And then, use the ImageKey for TreeNode.

Can you please advice on how to make this happen?

 

Thank you & regards,

Pavel Weiss

  • You must to post comments
0
0

The correct usage is:

this.imageList1.Images.Add(new ImageListEntry
{
    Name = "myImage"
    ImageSource = "myImage"
});

With Wisej.NET the ImageSource property is alternative to Image. Image is a System.Drawing.Image while ImageSource is a string. It takes a URL, a name of a themed image, a relative file path. See https://docs.wisej.com/docs/controls/general/icons#image-files.

You can put the code in your application. Write it or use the designer.

  • You must to post comments
0
1

which place I put this statement? inside my class?

 

this.imageList1.Images.Add(new ImageListEntry
{
    Name = "myImage"
    ImageSource = Application.Theme.Images["myImage"]
});



  • You must to post comments
0
0

Hi Pavel,

All theme resources are accessible using Application.Theme.

You can add them to an ImageList programatically:

this.imageList1.Images.Add(new ImageListEntry
{
    Name = "myImage"
    ImageSource = Application.Theme.Images["myImage"]
});

 

HTH,

Levie

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.