-3

我有一个在 mdi 父级中加载的子表单。这个子表单在加载时具有滑动效果,并且来自屏幕的左侧,并将设置在屏幕的中心(我用一个简单的计时器做到了这一点)。

问题是,如果我不将dockstyle表单设置fill为滚动条不起作用,如果我设置dockstylefill,滑动效果将不起作用并且表单加载简单!

这是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将以滑动效果加载

4

1 回答 1

0

我解决了!

我只是reservevaghtazar.Dock=DockStyle.Fill;在之后添加reservevaghtazar.Focus();

问题是我在幻灯片表单完全加载到屏幕之前停靠表单。我改变了停靠线的位置并解决了。

But yet Its very Strange that scrollbar doesnt work if the form doesnt be fill in Mdi parent.

于 2012-12-19T21:18:26.190 回答