0

基本的に、私が知っているあらゆる方法でこれを修正しようとしました。ここで私が間違っていることを誰かに教えてもらえますか?これはうまくいくはずです...

private void Main_Load(object sender, EventArgs e)
    {
        this.Size = new Size(0,0);
        timer2.Enabled = true ;

    }

    public void timer2_Tick(object sender, EventArgs e)
    {
        this.Width += 20;
        this.Height += 20;

        if (this.Height == 400)
        {
            timer2.Enabled = false;
        }

壮大な計画では、フォームのサイズを 100ms 間隔で一度に 20px ずつ変更しています。

編集:これは、非常に大雑把に、フォーム アニメーションを作成しようとしている私です。

4

2 に答える 2

2

次よりも大きい値を使用して、ifステートメントを修正する必要があります。

public void timer2_Tick(object sender, EventArgs e)
{
    this.Width += 20;
    this.Height += 20;

    if (this.Height >= 400)
    {
        timer2.Enabled = false;
    }
}

あなたの探求で頑張ってください。

于 2013-03-16T17:21:16.593 に答える
0
public void timer2_Tick(object sender, EventArgs e)
{

    if (this.Height < 400)
    {
        this.Height += 20;
        this.Width += 20;   

    }
    else
    {
        timer2.Enabled = false;
    }
}
于 2013-03-16T17:30:32.930 に答える