12

Could someone please explain what the difference is between using the ISupportInitialize interface methods (BeginInit/EndInit) and using SuspendLayout/ResumeLayout?

Is ISupportInitialize ONLY used during construction/"initial" initialization... or can it be used later when you want to add new child controls to an existing parent control?

Any particular differences?

I greatly appreciate your help!

Thank you,

Pato

Warren Rumak
  • 3,824
  • 22
  • 30
Pato
  • 207
  • 3
  • 7
  • --------------- Today I want to implement dynamic control creation by converting it from designer code. Which one take precedence? BeginInit() or SuspendLayout()? ---------------------- ((ISupportInitialize)Process_GroupControl).BeginInit(); Process_GroupControl.SuspendLayout(); – CallMeLaNN Mar 15 '11 at 08:59

2 Answers2

5

The interface ISupportInitialize lives in the System.dll and is just a fairly generic concept in the realm of Components. Incidentally, many parts of System.Windows.Forms are Components, and also Windows.Forms is the main user of the ComponentModel stuff.

Suspend/ResumeLayout is a pure Windows.Forms thing and really telling a control to not try and do graphics while you are e.g. adding child controls or changing properties.

flq
  • 22,247
  • 8
  • 55
  • 77
-1

Correct used code in VB.Net for this, most decompilers get this wrong.

CType(Me.pictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
SSpoke
  • 5,656
  • 10
  • 72
  • 124