C# winform ,如何使MDI子窗体被拖动超出父窗体边缘时,父窗体不出现滚动条

2024-12-13 16:57:42
推荐回答(3个)
回答1:

private void button1_Click(object sender, EventArgs e)
{
Form2 frm = new Form2();
frm.MdiParent = this;
frm.LocationChanged += new EventHandler(frm_LocationChanged);
frm.Show();
} void frm_LocationChanged(object sender, EventArgs e)
{
Form frm = (Form)sender;
if (frm.Location.X+frm.Width>this.Width)
{
frm.Left = this.Width - frm.Width;
}
if (frm.Location.Y+frm.Height>this.Height)
{
frm.Top = this.Height - frm.Height ;
}
}

回答2:

你可以试着限定死父窗体的大小,这样就不会有了

回答3:

这个只有让子窗体不能超过父窗体边缘了