想使PANEL分成三部分,然后按不同的时间依次将每部分的图背景变色,可以实现吗?如果可以的话该如何实现呢?

解决方案 »

  1.   

    这样..     private void button1_Click(object sender, EventArgs e)
            {
                Graphics _Graphics = Graphics.FromHwnd(panel1.Handle);            int _Height =panel1.Height/3;
                Rectangle _RectOn =new Rectangle(0,0,panel1.Width,_Height);
                Rectangle _RectIn = new Rectangle(0, _Height, panel1.Width, _Height);
                Rectangle _RectUnder =new Rectangle(0,_Height*2,panel1.Width,_Height);
                _Graphics.FillRectangle(Brushes.Red, _RectOn);
                _Graphics.FillRectangle(Brushes.Green, _RectIn);
                _Graphics.FillRectangle(Brushes.Blue, _RectUnder);            _Graphics.Dispose();        }
      

  2.   

        g = Graphics.FromHdc(panel1.Handle);
    出错了,说”值不在预期范围内“,怎么回事呢?
      

  3.   

    还有个问题,我先在panel 上drawline,然后fillrectangle,就把之前的线给覆盖了,怎么能让不覆盖线呢?