I want to maximize and minimize windows form on Timer Tick evebt. I placed the code

 this.WindowState = FormWindowState.Minimized;

into the timer tick event.

but actually its not working. Suggest me some code snippet for the same.

Regards,
Manthan

Following the code that i have used.

    private void timer1_Tick(object sender, EventArgs e)
    {

        if (FormWindowState.Maximized == this.WindowState)
        {
            f.WindowState = FormWindowState.Minimized;


                timer1.Stop();

        }

    }

 private void Form2_Load(object sender, EventArgs e)
        {
            f = new Form2();
            timer1.Enabled = true;
            timer1.Start();

        }

        private void timer1_Tick(object sender, EventArgs e)
        {

            if (FormWindowState.Maximized == this.WindowState)
            {
                f.WindowState = FormWindowState.Minimized;


                    timer1.Stop();

            }

        }

I assume you initialized the Timer somewhere else.
While in the form Load event of Form2, you create a new Form2? Seems a bit strange to me.

Agree with ddanbe, you're going to get yourself into a neverending loop there.

this.WindowState = FormWindowState.Minimized should work. What kind of timer are you using? Are you sure that the tick event is fired?

This article has been dead for over six months. Start a new discussion instead.