【问题标题】:MDI Child.show() displays the form in a weird mannerMDI Child.show() 以一种奇怪的方式显示表单
【发布时间】:2009-06-16 07:35:19
【问题描述】:

我有一个有 5 个 MDI 子级的主窗体。创建主窗体时,也会创建并显示 mdi 子窗体。

我在屏幕上为它们分配了不同的位置,但当它们显示时,它们会从默认位置开始,然后以令人不安的方式移动到新位置。我尝试在显示表单之前分配位置,但是在调用 the.Show() 之后,它们往往会转到某个默认位置。 有没有办法避免显示从默认位置到新位置的这种移动?

这是一个代码片段

groupSettingsForm.Show();
        groupSettingsForm.Location = new Point(0, 0);
        dsForm.Show();
        dsForm.Location = new Point(groupSettingsForm.Width, 0);
        dPlots.Show();
        dPlots.Location = new Point(groupSettingsForm.Width, dsForm.Height);
        alertsForm.Show();
        alertsForm.Location = new Point(groupSettingsForm.Width, dsForm.Height + dPlots.Height);
        dataValuesForm.Show();
        dataValuesForm.Location = new Point(0, groupSettingsForm.Height);

我试过了,但它不适合我

   groupSettingsForm.Location = new Point(0, 0);
        groupSettingsForm.Show();

        dsForm.Location = new Point(groupSettingsForm.Width, 0);
        dsForm.Show();

        dPlots.Location = new Point(groupSettingsForm.Width, dsForm.Height);
        dPlots.Show();

        alertsForm.Location = new Point(groupSettingsForm.Width, dsForm.Height + dPlots.Height);
        alertsForm.Show();

        dataValuesForm.Location = new Point(0, groupSettingsForm.Height);
        dataValuesForm.Show();

【问题讨论】:

    标签: c# .net winforms mdi


    【解决方案1】:

    我刚刚有类似的东西 - my question can be found here

    您需要将StartPosition 属性设置为FormStartPosition.Manual

    form.StartPosition = FormStartPosition.Manual;
    form.Location = new System.Drawing.Point(0, 0);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-26
      • 1970-01-01
      • 1970-01-01
      • 2017-01-17
      • 2017-12-04
      • 1970-01-01
      • 1970-01-01
      • 2019-08-03
      相关资源
      最近更新 更多