我想将一个全局变量的数组A[k]画在PictureBox上,A[k]->k.
不知道该怎么画我想在Filter.cs的一个函数Hilber()中画.但PicturBox这个控件是在Form1中的,而Form1的代码在Form1.cs中.我是初学者,根本不懂代码该往那里加.我只是想等程序跑完以后,将所有A[k]中的point画出来,请大家帮助了非常感谢,鉴于在下水平业余,还请指点地详细一些万分感谢!

解决方案 »

  1.   

    你可以将pictureBox控件作为Hilber()函数的参数
      

  2.   

    using System;namespace WindowsApplication7
    {
    /// <summary>
    /// Class1 的摘要说明。
    /// </summary>
    public class Filter
    {
    public Filter()
    {
    //
    // TODO: 在此处添加构造函数逻辑
    //
    } public void Hilber(System.Windows.Forms.PictureBox pic,System.Collections.ArrayList ps)
    {

    System.Drawing.Graphics g = pic.CreateGraphics();
    System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Red);
    //集合中的坐标点必须大于一个
    if (ps.Count >1)
    {
    for(int i=1 ; i<ps.Count ; i++)
    {
    g.DrawLine(pen,(System.Drawing.Point)ps[i-1],(System.Drawing.Point)ps[i]);
    }
    }
    pen.Dispose();
    g.Dispose();
    }
    }
    }
    调用
    private void button1_Click(object sender, System.EventArgs e)
    {
    ps = new ArrayList();
    ps.Add(new Point(10,10));
    ps.Add(new Point(20,30));
    ps.Add(new Point(50,100));
    Filter filter = new Filter();
    filter.Hilber(this.pictureBox1,ps);
    }
      

  3.   

    不太明白...如何将PictureBox作为Hilber()的参数呢?