我想用C#显示出数轴,并在上面画出几个点.

解决方案 »

  1.   

    private void Form1_Paint(object sender, PaintEventArgs e)
    {
        e.Graphics.DrawLine(Pens.Black, new Point(0, ClientSize.Height / 2),
            new Point(ClientSize.Width, ClientSize.Height / 2));
        e.Graphics.DrawLine(Pens.Black, new Point(ClientSize.Width / 2, 0),
          new Point(ClientSize.Width / 2, ClientSize.Height));    //todo : 其他绘制
    }
      

  2.   

    感谢zswang的回复```我试试看```
      

  3.   

    可以用Graphic来绘,可以参看msdn中关于graphic的用法,如果图形复杂的话,可以考虑第三方控件,参见
    http://blog.csdn.net/tjvictor/archive/2006/11/24/1412546.aspx
      

  4.   

    zswang, I have coyied the code to program, but nothing display.
    Is there any code needed?
    Thanks.(I am in university lab, the system is in English,so...)
      

  5.   

    将代码放到Form1的Paint事件里执行private void button1_Click(object sender, EventArgs e)
    {
        Graphics vGraphics = Graphics.FromHwnd(Handle);
        vGraphics.DrawLine(Pens.Black, new Point(0, ClientSize.Height / 2),
             new Point(ClientSize.Width, ClientSize.Height / 2));
        vGraphics.DrawLine(Pens.Black, new Point(ClientSize.Width / 2, 0),
          new Point(ClientSize.Width / 2, ClientSize.Height));
    }简单来说就是通过Graphics类的DrawLine()方法绘制直线
      

  6.   

    Cheers. I will try it.
      

  7.   

    CSDN - 技术社区 - .NET技术 C#  
     回复 | 收藏此页 | 专题 | 公告 | [[[[管理]]]]] | 保存 | 关闭窗口   点上面的[管理]按提示给分 -.-#