Home
Options

How to load an image in ImageList

Probably it is a very silly question, but I need to load some bitmap images into an ImageList control in a Winforms Framework, in a FormattingToolStrip.linq. The bitmap files are in the same folder.

This line: imglst.Images.Add("BackColor", new Bitmap(GetType(), "ChooseColor.bmp"));
generates an error: Resource 'ChooseColor.bmp' cannot be found in class 'UserQuery+FormattingToolStrip'.

Util.Image("ChooseColor.bmp").Dump(); generates Invalid URI: The format of the URI could not be determined.

Util.Image(Path.Combine(absPath, "ChooseColor.bmp")).Dump(); works fine.

So, I tried:
imglst.Images.Add("BackColor", (Image)Util.Image(Path.Combine(absPath, "ChooseColor.bmp")));
But it generates Unable to cast object of type 'LINQPad.ObjectGraph.ImageRef' to type 'System.Drawing.Image'.

Any directions?

Comments

Sign In or Register to comment.