using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace 网络五子棋2
{
    public partial class Form1 : Form
    {
        private Graphics draw;
        private PictureBox pb;
        public Form1()
        {            InitializeComponent();
            //start();
        }        private void start()
        {            draw = pb.CreateGraphics();
            Pen mypen = new Pen(Color.Red, 3);
            Rectangle rect = new Rectangle(50, 70, 256, 256);
            draw.DrawRectangle(mypen, rect);
            for (int i = 1; i <= 15; i++)
            {
                draw.DrawLine(mypen, 50 + 16 * i, 70, 50 + 16 * i, 326);
                draw.DrawLine(mypen, 50, 16 * i + 70, 306, 16 * i + 70);
            }        }
}

解决方案 »

  1.   


            protected override void OnPaint(PaintEventArgs e)
            {
                base.OnPaint(e);
            }
      

  2.   

    OnPaint 控件会自行维护的。当然你也可以用Invalid强制刷新控件界面
      

  3.   

     public Form1()
            {            InitializeComponent();
                
            }
    我想在这里引用,求指导
      

  4.   

    我在事件里找到一个piont,是这个不,不过我尝试了还是不行public Form1()
             {
     
                InitializeComponent();
                 
             }
     我想在这里引用,求指导 
      

  5.   

    public Form1()
             {
     
                InitializeComponent();
                this. this.Paint += new PaintEventHandler(Form1_Paint);
            
                 
             }
      

  6.   

    直接给窗体赋背景图片就可以了咯,然后invalid一下,这个窗体就行了,在invalid的时候会出现闪烁,这里给当前的窗体设一下缓冲,一个属性叫什么忘了,把他设成true。你那个写法也可以的呢
      

  7.   

          private void start()
            {            draw = pb.CreateGraphics();
                改为:draw=this.creategraphics();
      

  8.   

    十四楼还是不行哦,我尝试了下只有在picturebox1下添加点击事件是可以显示的