开发者

Set ImageAnnoation image using embedded Resources instead of a file name

I'm using the Chart control from the DataVisualization library, and want to use image annotations on my chart. The problem is that the ImageAnnotation.Image property is a path to the image, and there doesn't appear to be an exposed Bitmap property that I could use to load the image from the R开发者_如何学Goesources object like I can for any other .net control.

Is there anyway I'm overlooking to load this using embedded resources instead of reading a separate file off the disk?


I found the answer. You need to add the image to the parent Chart's NamedImage collection.

private string imageName = "myImage";

//in constructor
NamedImage namedImage = new NamedImage(imageName, Properties.Resources.myImage);
mChart.Images.Add(namedImage);

//where creating the annotation
ImageAnnotation imageAnnotation = new ImageAnnotation();
imageAnnotation.Image = imageName;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜