拜托了
我是小鸟,分都问完了

解决方案 »

  1.   

    是不是刷新一下就没了? 我对GUI也不太懂, 下面的是以前的一个作业, 画直线, 希望能对楼主有说帮助using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace 画直线_Demo_02101434_陈剑
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
            private System.Windows.Forms.PictureBox picDrawLine;
            private Pen myPen;
            private bool drawState;
            private Graphics gTemp;
            private Graphics g;
            private int x, y;
            private int xD, yD;            /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null; public Form1()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows 窗体设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
                System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
                this.picDrawLine = new System.Windows.Forms.PictureBox();
                this.SuspendLayout();
                // 
                // picDrawLine
                // 
                this.picDrawLine.BackColor = System.Drawing.Color.White;
                this.picDrawLine.Image = ((System.Drawing.Image)(resources.GetObject("picDrawLine.Image")));
                this.picDrawLine.Location = new System.Drawing.Point(5, 5);
                this.picDrawLine.Name = "picDrawLine";
                this.picDrawLine.Size = new System.Drawing.Size(370, 305);
                this.picDrawLine.TabIndex = 0;
                this.picDrawLine.TabStop = false;
                this.picDrawLine.MouseUp += new System.Windows.Forms.MouseEventHandler(this.picDrawLine_MouseUp);
                this.picDrawLine.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picDrawLine_MouseMove);
                this.picDrawLine.MouseDown += new System.Windows.Forms.MouseEventHandler(this.picDrawLine_MouseDown);
                // 
                // Form1
                // 
                this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
                this.ClientSize = new System.Drawing.Size(377, 315);
                this.Controls.Add(this.picDrawLine);
                this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
                this.Name = "Form1";
                this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                this.Text = "画直线_Demo_02101434_陈剑";
                this.Load += new System.EventHandler(this.Form1_Load);
                this.ResumeLayout(false);        }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    }        private void Form1_Load(object sender, System.EventArgs e)
            {
                gTemp = this.picDrawLine.CreateGraphics();
                myPen = new Pen(Brushes.Blue, 2);
                g = System.Drawing.Graphics.FromImage(this.picDrawLine.Image);
            }        private void picDrawLine_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
            {
                drawState = true;
                xD = x = e.X;
                yD = y = e.Y;
            }        private void picDrawLine_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
            {
                if (drawState == true)
                {
                    gTemp.DrawLine(new Pen(Brushes.White, 2), x, y, xD, yD);
                    
                    gTemp.DrawLine(myPen, x, y, e.X, e.Y);
                    this.Refresh();
                    xD = e.X;
                    yD = e.Y;
                    
                    //this.picDrawLine.Image.Save("paint.bmp");
    //                this.picDrawLine.BackgroundImage.Save("paint.bmp");
                }
            }        private void picDrawLine_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
            {
                if (drawState == true)
                {
                    drawState = false;
                    g.DrawLine(myPen, x, y, e.X, e.Y);
                    //gTemp.Clear(Color.White);
                    this.Refresh();
                }
            }
    }
    }
      

  2.   

    你应该在paint事件中绘制,这样最小化后再还原时,会重新绘制
      

  3.   

    重写OnPaint 把绘制操作写在当中