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 drawing itself again?

Using Windows Forms and .NET 4

Answers


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);
        }
    }

Need Your Help

Why is my simple laravel query returning a recursion?

php mysql laravel recursion eloquent

I have two Eloquent models which are in a one to one relationship: A mission has one vehicle, and a vehicle belongs to one mission.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.