在图表图例中的新行中打印列表字符串

时间:2014-06-02 12:49:58

标签: c# c#-4.0 charts datatable legend

我有一个字符串列表,我在图表图例中打印。 我想在图表图例中将列表中的字符串打印在另一个下面

List<string> list = new List<string>();

if (table7.Columns.Contains(colx))
{
    for (int yy = 0; yy < table7.Rows.Count; yy++)
    {

        double tval = double.Parse(table7.Rows[yy][colx].ToString());

        if (tval < lower || tval > upper)
        {

            list.Add(table7.Rows[yy]["Die_ID"].ToString());
        }
    }
}

//列表中的字符串打印在一行中我想一个接一个地打印它们

LegendItem firstItem = new LegendItem();
Font f = new Font("Serif", 14, FontStyle.Bold);

foreach (string s in list)
{
      LegendCell firstCell = new LegendCell(LegendCellType.Text, "" + s, ContentAlignment.BottomRight);

      firstCell.Font = f;
      firstItem.Cells.Add(firstCell);
}

1 个答案:

答案 0 :(得分:0)

        LegendItem firstItem = new LegendItem();
        Font f = new Font("Serif", 14, FontStyle.Bold);

        LegendCell firstCell = new LegendCell();


        for (int l = 0; l < list.Count;l++ )
        {

            firstCell.Text = list[l] + Environment.NewLine  +firstCell.Text;

            firstCell.Font = f;

        } firstItem.Cells.Add(firstCell);