Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Why use SuspendLayout()?

Tags:

c#

winforms

I am reading up about SuspendLayout() and ResumeLayout(). What I can't figure out is, why should I do/use this. I know you use it when you add controls at runtime to a control-container.

It has something to do with setting properties like Dock, Anchor, Location, etc.

But I don't understand what the additional value is of Suspend- and ResumeLayout(). What does these methods take care for?

like image 494
Martijn Avatar asked Oct 01 '10 10:10

Martijn


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

Why do we write C?

It was mainly developed as a system programming language to write an operating system. The main features of the C language include low-level memory access, a simple set of keywords, and a clean style, these features make C language suitable for system programmings like an operating system or compiler development.


1 Answers

Basically it's if you want to adjust multiple layout-related properties - or add multiple children - but avoid the layout system repeatedly reacting to your changes. You want it to only perform the layout at the very end, when everything's "ready".

like image 199
Jon Skeet Avatar answered Sep 22 '22 02:09

Jon Skeet