本文介绍了如何设置MS Chart LegendItem图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在WinForms中使用资源中的图像到LegendItem
I use Image from Resources to LegendItem in WinForms
var ImageName = "ImageName";
myChart.Images.Add(new NamedImage(ImageName, Resources.Image));
LegendItem legendItem = new LegendItem();
legendItem.Name = "legend text";
legendItem.Image = ImageName;
myChart.Legends[Legend.Name].CustomItems.Add(legendItem);
但是图像的尺寸太小.我该如何更改?
But the size of Image is too small.How can I change it?
推荐答案
在这种情况下,您应该使用自定义LegendCell.这意味着您可以为LegendItem定义单元格并指定其属性.像这样:
You should use custom LegendCell in this case. This means you define the cells for your LegendItem specifying their properties. Something like this:
LegendItem legendItem = new LegendItem();
LegendCell cell1 = new LegendCell();
cell1.Name = "cell1";
cell1.Text = "legend text";
// here you can specify alignment, color, ..., too
LegendCell cell2 = new LegendCell();
cell2.Name = "cell2";
cell2.CellType = System.Windows.Forms.DataVisualization.Charting.LegendCellType.Image;
cell2.Image = "path of your img";
cell2.Size = new Size(.....);
legendItem.Cells.Add(cell1);
legendItem.Cells.Add(cell2);
这篇关于如何设置MS Chart LegendItem图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!