开发者

How can I tell a control to NOT redraw itself?

I've tried something like:

horizontalPictureScroller1.SuspendLayout();
horizontalPictureScroller1.DeleteSelectedImages();
horizontalPictureScroller1.ResumeLayout();

But it's still lagging visually when I run the DeleteSelectedImages() method.

Is there some way to manually tell a control to NOT redraw itself until I tell it to start dr开发者_如何学JAVAawing itself again?

Using Windows Forms and .NET 4


I suppose that your problem is that your screen updates during the delete operation resulting in flickering.

The SuspendLayout and ResumeLayour methods only suspend the layout of the control. It does not stop the control from redrawing or resizing.

You should enable DoubleBuffering on the control.

You should create a new control class derived from the WinForms control you are using here. In the constructor of this class enable the double buffering using SetStyle method.

Assuming that your control horizontalPictureScroller1 is a PictureBox -

class MyControl : System.Windows.Forms.PictureBox
    {
        public MyControl()
        {
            this.SetStyle(ControlStyles.DoubleBuffer |
                ControlStyles.UserPaint |
                ControlStyles.AllPaintingInWmPaint,
                true);
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜