0

我在 WinForms 中使用资源中的图像到 LegendItem

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);

但是 Image 的尺寸太小了。我怎样才能改变它?

4

1 回答 1

1

在这种情况下,您应该使用自定义 LegendCell。这意味着您为 LegendItem 定义单元格并指定它们的属性。像这样的东西:

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);
于 2013-06-05T09:07:15.080 回答