我有一个以mdi parent加载的子表单。这个子表单在加载时有滑动效果,从屏幕左侧开始,将设置在屏幕中心(我用简单的计时器完成)。
问题在于,如果我没有将表单的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
将加载滑动效果
答案 0 :(得分:0)
我解决了!
我只是在reservevaghtazar.Dock=DockStyle.Fill;
reservevaghtazar.Focus();
问题是我在幻灯片表单完全加载到屏幕之前对接表单。我改变了对接线的位置并解决了。
但是如果表单没有填写Mdi父级,那么滚动条无法正常运行。