public static int iGeShu = 5;
        public static int iLeiXing = 2;
        private static string sWenBen = "天上星河转人间帘幕垂凉生枕簟泪痕滋起解罗衣聊问夜何";
        struct UserSheet
        {
            public bool visbile;
            public int index;
            public string str;
            public Rectangle rect;
            public int x()
            { return rect.X; }
            public int y()
            { return rect.Y; }
            public int width()
            { return rect.Width; }
            public int height()
            { return rect.Height; }
        }
        private UserSheet[,] mySheet = new UserSheet[10, 10];
        private const int iSheetsWidth = 540;
        private int iSheetWidth = iSheetsWidth / iGeShu;
        private int iSheetLeft = 240;
        private int iSheetTop = 100;
        private int fontSize = 300 / iGeShu;
        private void UserControlZhuYiRun_Paint(object sender, PaintEventArgs e)
        {
            if (iGeShu != 0)
            {
                Graphics graphics = e.Graphics;                for( int i = 0; i <= iGeShu; i++)
                {
                    graphics.DrawLine(new Pen(Color.Black, 2), new Point(iSheetLeft, i * iSheetWidth + iSheetTop), new Point(iSheetLeft + iSheetsWidth, i * iSheetWidth + iSheetTop));
                    graphics.DrawLine(new Pen(Color.Black, 2), new Point(i * iSheetWidth + iSheetLeft, iSheetTop), new Point(i * iSheetWidth + iSheetLeft, iSheetTop + iSheetsWidth));
                }                for (int i = 0; i < iGeShu; i++)
                    for (int j = 0; j < iGeShu; j++)
                        if (mySheet[i, j].visbile)
                            graphics.FillRectangle(new SolidBrush(Color.Black), mySheet[i, j].rect);                Font drawFont = new Font("Arial", fontSize);
                StringFormat drawFormat = new StringFormat();
                drawFormat.Alignment = StringAlignment.Center;
                RectangleF drawRect;
                for (int i = 0; i < iGeShu; i++)
                {
                    for (int j = 0; j < iGeShu; j++)
                    {
                        drawRect = new RectangleF(mySheet[i, j].x(), mySheet[i, j].y() + (mySheet[i, j].height() - drawFont.Height) / 2, mySheet[i, j].width(), mySheet[i, j].height());
                        graphics.DrawString(mySheet[i, j].str, drawFont, new SolidBrush(Color.Beige), drawRect, drawFormat);
                    }
                }
            }
        private void UserControlZhuYiRun_MouseDown(object sender, MouseEventArgs e)
        {
            mySheet[(e.X - iSheetLeft) / iSheetWidth, (e.Y - iSheetWidth) / iSheetWidth].visbile = true;
            this.Refresh();
        }

解决方案 »

  1.   

    您可以参考一下MSDN上GDI+绘图及双缓冲技术,直接对屏幕绘图肯定会闪烁的,
    UserControlZhuYiRun_Paint时间是哪个控件触发的?我所用过的控件中,只有PictureBox返回的Graphics绘图不会闪,别的都会闪,因为PictureBox内置了双缓冲处理图形
    GDI+:ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_fxmclignrl/html/a98a76ab-e455-49c9-891c-0491ac932f2c.htm
    双缓冲:ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_fxmclignrl/html/dc484e33-7101-4e4b-ada5-d3c96155fbcd.htm
      

  2.   

    谢谢,我找到了
    Invalidate方法