Bringtofront()在ResumeLayout之前或之后去了吗?有关系吗?

时间:2014-11-11 18:14:07

标签: c# winforms .net-3.5 compact-framework windows-mobile-6.5

所以我一直在挖掘整个SuspendLayout()/ ResumeLayout()逻辑一段时间,我一直在尝试以最有效的方式实现它。我无法找到答案的一个问题是我在标题中提到的问题:BringToFront()方法是在调用ResumeLayout()之前还是之后进行的?有关系吗?我最初的思考过程不是,没关系,因为它只是改变控件的z-index而不影响控件的布局,但我只是想确定。

这是我的项目中的代码块,我的问题发挥作用:

注意:此项目在Motorola MC65移动设备上运行并使用.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();
}

我的问题是对此部分感兴趣:

    ResumeLayout(false);

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

    HostControl.ResumeLayout();

另外,我是否正确使用它?谢谢你的时间。

0 个答案:

没有答案