c#,如何在指定位置show出我的子窗体?

2024-12-13 10:34:48
推荐回答(3个)
回答1:

正下方吗,这么写就行了

private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
Point startPoint = PointToScreen(button1.Location);
startPoint.Y += button1.Height;
f2.StartPosition = FormStartPosition.Manual;
f2.Location = startPoint;
f2.Show();
}

回答2:

'在子窗体里添加代码:
Private Sub Form_Load()

'在MDI窗体的正中
Me.Top = (MDIForm1.ScaleHeight - Me.Height) / 2
Me.Left = (MDIForm1.ScaleWidth - Me.Width) / 2

'左上角
'Me.Top = 0
'Me.Left = 0

回答3:

按钮的正下方的坐标为:
Point lctn = new Point();
lctn.X=btn.left;
lctn.Y=btn.Top+btn.Height;