想给PictureBox 通过重绘(GDI+)的方式加个边框,怎么不行了?问题很简单,就是想给PictureBox1加个边框...private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = this.CreateGraphics();
            g.DrawRectangle(new Pen(Color.Blue, 2), e.ClipRectangle);
            g.Dispose();        }这事件也触发了,但就是没有效果, 请各位大侠帮我看看.btw, 这个PictureBox1 是在用户控件里的.

解决方案 »

  1.   

    改成如下:
    private   void   pictureBox1_Paint(object   sender,   PaintEventArgs   e) 
                    { 
                            e.Graphics.DrawRectangle(new   Pen(Color.Blue,   2),   e.ClipRectangle);                 } 建立如下:
    private void pictureBox1_Paint(object sender, PaintEventArgs e)
    {
    Rectangle bound = Rectangle.FromLTRB(0, 0, pictureBox1.Width-1, this.pictureBox1.Height- 1);
    ControlPaint.DrawBorder(e.Graphics, bound, SystemColors.ControlDark, ButtonBorderStyle.Solid);
    }
      

  2.   

    WinForm上放置一个有阴影边框的矩形面板
      

  3.   

    private void pictureBox1_Paint(object sender, PaintEventArgs e)
    {
    PictureBox UserHeadImg = (PictureBox)sender;
    Pen UserHeadImgPen = new Pen(Color.Red);
    e.Graphics.DrawRectangle(UserHeadImgPen, e.ClipRectangle);
    }