我有一个在 mdi 父级中加载的子表单。这个子表单在加载时具有滑动效果,并且来自屏幕的左侧,并将设置在屏幕的中心(我用一个简单的计时器做到了这一点)。
问题是,如果我不将dockstyle
表单设置fill
为滚动条不起作用,如果我设置dockstyle
为fill
,滑动效果将不起作用并且表单加载简单!
这是form1中的按钮:
Timer timerPrevMonth = new Timer();
//reserve_vaght_azar is the form that will be load in sliding effect
reserve_vaght_azar reservevaghtazar = null;
private void btn_prev_dey_Click(object sender,EventArgs e)
{
reservevaghtazar = new reserve_vaght_azar();
reservevaghtazar.StartPosition = FormStartPosition.Manual;
reservevaghtazar.Location = new Point( this.Location.X-Width,Location.Y );
reservevaghtazar.MdiParent = MdiParent;
this.TopMost = true;
//here is dockstyle
// reservevaghtazar.Dock=DockStyle.Fill;
reservevaghtazar.Show();
timerPrevMonth.Start();
}
这是计时器功能:
void timerPrevMonth_Tick(object sender,EventArgs e)
{
timerPrevMonth.Stop();
reservevaghtazar.Location = new Point( reservevaghtazar.Location.X +15,this.Location.Y );
if (this.Location.X-reservevaghtazar.Location.X <5)
{
reservevaghtazar.Location = new Point( this.Location.X,this.Location.Y );
this.TopMost = false;
reservevaghtazar.BringToFront();
reservevaghtazar.Focus();
}
else
timerPrevMonth.Start();
}
当在form1中按下按钮时,表单reserve_vaght_azar
将以滑动效果加载