继承picturebox,然后重载Paint函数。OverRide

解决方案 »

  1.   

    public class myPictureBox : System.Windows.Forms.PictureBox
    {
    public myPictureBox()
    { } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
    base.OnPaint(e);
    } }
      

  2.   

    还是不懂
    protected override void OnPaint(PaintEventArgs e)
    {
    Graphics g= e.Graphics;
    g.FillRectangle(Brushes.White,this.ClientRectangle);
    GraphicsPath gp=new GraphicsPath();
    gp.AddEllipse(20, 20, 300, 200);
    gp.AddPie(50, 100, 300, 100, 45, 200);
    gp.AddRectangle(new Rectangle(100, 30, 100, 80));
    g.DrawPath(Pens.Blue, gp);
    g.TranslateTransform(200, 20);
    g.FillPath(Brushes.GreenYellow, gp);
    gp.Dispose();
    }
    这个是画在form上的,怎样才能将它画在picturebox上??
      

  3.   

    你重写System.Windows.Forms.PictureBox就是画在PictureBox上罗
    public class myPictureBox : System.Windows.Forms.PictureBox
    {...
    protected override void OnPaint(PaintEventArgs e)
    {...}