c#在对象上绘制文本

时间:2011-05-23 18:52:16

标签: c#

我正在使用此方法在对象上绘制虚线:

// Get Graphics object from chart
        Graphics graph = e.ChartGraphics.Graphics;

        PointF point1 = PointF.Empty;
        PointF point2 = PointF.Empty;

        // Set Maximum and minimum points
        point1.X = -110;
        point1.Y = -110;
        point2.X = 122;
        point2.Y = 122;

        // Convert relative coordinates to absolute coordinates.
        point1 = e.ChartGraphics.GetAbsolutePoint(point1);
        point2 = e.ChartGraphics.GetAbsolutePoint(point2);

        // Draw (dashed) connection line
       float[] dashValues = { 4, 2 };
       Pen dashPen= new Pen(Color.Yellow, 3);
       dashPen.DashPattern = dashValues;
       graph.DrawLine(dashPen, point1, point2);

我想知道是否可以用同样的方式在对象上写文本/.??

2 个答案:

答案 0 :(得分:3)

您应该查看DrawString方法。

答案 1 :(得分:2)

是的,您可以在Graphics.DrawString

中完成此操作