试过修改目标窗体,Startposition中的 CenterScreen 和 CenterParent 都没用。
我是这样调用窗体的。我想让窗体:msdb_setup 在panel中居中。(上下、左右都居中)private void 设置数据库ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            main_park_lee_panel.Controls.Clear();
            msdb_setup oldset = new msdb_setup();
            oldset.TopLevel = false;
            main_park_lee_panel.Controls.Add(oldset);
            oldset.Show();
        }

解决方案 »

  1.   


                main_park_lee_panel.Controls.Clear();
                msdb_setup oldset = new msdb_setup();
                oldset.TopLevel = false;
                oldset.Location = new Point((main_park_lee_panel.Width - oldset.Width) / 2, (main_park_lee_panel.Height - oldset.Height) / 2);
                main_park_lee_panel.Controls.Add(oldset);
                oldset.Show();
      

  2.   

    居中:
    Self.Left = Parent.Width / 2 - Self.Width / 2 => (Parent.Width - Self.Width) / 2
    Self.Top = Parent.Height / 2 - Self.Height / 2 => (Parent.Height - Self.Height) / 2