Hold Control.SuspendLayout and Control.ResumeLayout?

I can’t remember how to correctly formulate the question, but, I hope, my meaning will be clear. Hold Control.SuspendLayout and Control.ResumeLayout?

In other words, if I call SuspendLayout and ResumeLayout twice once, is the layout still paused?

+3
source share
2 answers

There are few reasons to get stuck on such a question. The source code is available under the name "Link Source". The best way to get this is with the .NET Mass Downloader . Not every .NET assembly has published the source code; your backup is a venerable Reflector .

Anyhoo, :

private byte layoutSuspendCount;

public void SuspendLayout() {
  layoutSuspendCount++;
  if (layoutSuspendCount == 1) OnLayoutSuspended();
}

public void ResumeLayout() {
  ResumeLayout(true);
}

public void ResumeLayout(bool performLayout) {
  if (layoutSuspendCount > 0) {
    if (layoutSuspendCount == 1) OnLayoutResuming(performLayout);
    layoutSuspendCount--;
    if (layoutSuspendCount == 0 && performLayout) {
      PerformLayout();
    }
  }
} 

internal void PerformLayout(LayoutEventArgs args) {
  if (layoutSuspendCount > 0) {
    //...
    return;
  }
  //etc...
}

, : .

+7

SuspendLayout ResumeLayout , ?

. .

-3

Source: https://habr.com/ru/post/1721516/


All Articles