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

Recommended Answers

All 6 Replies

Could you show the code on how you implemented the Timer. Is the Timer started?

I have enabled the timer using enable property

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.

Ok i got it... Thanxxx for the help...

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.