问题解决了。CustomItem 方法也不起作用,所以我尝试使用 LegendCellColumn 类。
我将 LegendStyle 从 Column 更改为 Row,然后添加了两个 CellColumn,一个用于系列符号,一个用于图例文本。设置对齐方式、边距和列宽(原来是诀窍),瞧;一个看起来像我想要的传奇。这是任何有类似问题的人的代码。
chartSel.Legends[ySeries.Name].CellColumns.Add(new LegendCellColumn("", LegendCellColumnType.SeriesSymbol, ""));
chartSel.Legends[ySeries.Name].CellColumns[0].Alignment = ContentAlignment.TopLeft;
chartSel.Legends[ySeries.Name].CellColumns[0].Margins = new System.Windows.Forms.DataVisualization.Charting.Margins(0, 0, 1, 1);
chartSel.Legends[ySeries.Name].CellColumns[0].MinimumWidth = 250;
chartSel.Legends[ySeries.Name].CellColumns[0].MaximumWidth = 250;
chartSel.Legends[ySeries.Name].CellColumns.Add(new LegendCellColumn("", LegendCellColumnType.Text, ySeries.Name));
chartSel.Legends[ySeries.Name].CellColumns[1].Alignment = ContentAlignment.MiddleLeft;
chartSel.Legends[ySeries.Name].CellColumns[1].Margins = new System.Windows.Forms.DataVisualization.Charting.Margins(0, 0, 1, 1);
chartSel.Legends[ySeries.Name].CellColumns[1].MinimumWidth = 1500;
chartSel.Legends[ySeries.Name].CellColumns[1].MaximumWidth = 1500;
这可能不是最有效的方法,但它确实有效。从技术上讲,图例符号和文本仍然在对象中居中,但是因为我强制调整两列的宽度,所以它看起来像是左对齐的。
希望这可以帮助像我这样的另一个新手避免惊慌失措的日子。