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

How to make conversions from varchar to datetime deterministic?

sql sql-server sql-server-2005 user-defined-functions deterministic

In the tradition of this question and in light of the documentation, how does one make this function deterministic:

PyroCMS - Show Blog Posts with date in future

pyrocms

in my PyroCMS website I want to display rock shows of a rock band that will occur in the future. I use a conditional to check whether the date of the blog post (which contains the rock show informa...

How to add dynamic customized ShareThis button?

javascript social sharethis

I would like to use ShareThis on my site and add multiple buttons for the same service to share multiple objects. This is possible but I could only get the buttons to be in one of the default style...

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.