你需要編寫Move
和Resize
活動相適應的其他形式。如果兩者都能夠移動,總是粘在一起,則需要爲兩者編寫事件;試試看能不能創造一個無限循環;-)
下面是一個例子:
private void Form1_Move(object sender, EventArgs e)
{
// you may or may not need this flag
// you would set and clear in the form's constructor and at the end of the Load event.
if (loading) return;
placeForm2();
}
private void Form1_Resize(object sender, EventArgs e)
{
placeForm2();
}
public void placeForm2()
{
form2.Top = this.Top;
form2.Left = this.Left + this.Width;
int sw = Screen.FromControl(this).WorkingArea.Width;
int sh = Screen.FromControl(this).WorkingArea.Height;
if (form2.Right >= sw) form2.Left = this.Left - form2.Width;
if (form2.Bottom >= sh) form2.Top = sh - form2.Height;
}
一個呼叫只需添加到placeForm2
功能,以您的按鈕點擊以及..!
請注意,當您接近右側屏幕邊框時,我將第二個窗體從左側移動到右側。這是可選的,當然..
來源
2016-08-21 16:31:33
TaW
你是什麼意思*作爲滑動條出來*? –
也許你的意思是側邊欄? –
@RezaAghaei是邊欄 – Rafi