2011-02-11 66 views
2

我使用DataVisualization庫中的Chart控件,並且希望在我的圖表上使用圖像註釋。問題是ImageAnnotation.Image屬性是圖像的路徑,並且似乎沒有公開的Bitmap屬性,我可以使用該屬性從Resources對象加載圖像,就像我可以爲任何其他.net控件一樣。使用嵌入式資源而不是文件名設置ImageAnnoation圖像

是否有反正我忽略加載這使用嵌入式資源,而不是從磁盤讀取單獨的文件?

回答

5

我找到了答案。您需要將圖像添加到父圖表的NamedImage集合中。

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

感謝您的回答丹,我正在調查相同的問題,並找到您的解決方案。我會試試這個:D – DeveloperDavid 2014-05-04 16:14:18