Does Bringtofront() go before or after ResumeLayout? Does it matter?

161 views Asked by At

So I've been digging into the whole SuspendLayout()/ResumeLayout() logic for a while now and I've been trying to implement it in the most efficient manner. One question I'm unable to find an answer for is that of which I've asked in the title : Does the BringToFront() method go before or after you call ResumeLayout()? Does it matter? My initial thought process is no, it doesn't matter, because it's only changing the z-index of the control and not effecting the control's layout, but I just want to be sure.

Here's block of code from my project where my question comes into play:

Note:This project runs on a Motorola MC65 mobile device and uses .net compact 3.5 framework

 /// <summary>
/// Initializes the <see cref="VerifyReplacementPanel"/> class
/// </summary>
/// <param name="hostControl">The panel this control is being added to</param>
/// <param name="original">The product being replaced</param>
/// <param name="replacement">The product replacing with</param>
/// <param name="logHelper">The log helper interface</param>
public VerifyReplacementPanel(Control hostControl, ProductModel original, ProductModel replacement, ILogHelper logHelper)
{
    hostControl.SuspendLayout();
    SuspendLayout();

    HostControl = hostControl;
    Product = original;
    Replacement = replacement;
    _logHelper = logHelper;

    Size = Size.FullScreen();

    // original product panel
    var panOrig = new blkPan(472, 75) { Location = new Point(4, 147), BackColor = Color.White };
    var originalProductPanel = new ProductPanelArrayModel(panOrig, _logHelper);
    originalProductPanel.AddPanelWithPic(original);
    Controls.Add(panOrig);

    // replacement product panel
    var panRepl = new blkPan(472, 75) { Location = new Point(4, panOrig.B + 100), BackColor = Color.White };
    var replacementProductPanel = new ProductPanelArrayModel(panRepl, _logHelper);
    replacementProductPanel.AddPanelWithPic(replacement);
    Controls.Add(panRepl);

    // no button
    var btnNo = new PushButton("No", ObjectName, true) { Location = new Point(38, Bottom - 93 - 36) };
    btnNo.Click += btnNo_Click;
    Controls.Add(btnNo);
    _btnNoTop = btnNo.Top;

    // yes button
    var btnYes = new PushButton("Yes", ObjectName, true) { Location = new Point(259, btnNo.Top) };
    btnYes.Click += btnYes_Click;
    Controls.Add(btnYes);

    ResumeLayout(false);

    HostControl.Controls.Add(this);
    BringToFront();

    HostControl.ResumeLayout();
}

My question is interested in this section :

    ResumeLayout(false);

    HostControl.Controls.Add(this);
    BringToFront();

    HostControl.ResumeLayout();

Also, am I even using it correctly? Thank you for your time.

0

There are 0 answers