0

i try to close the from and open it again with this code bout it didn't close the form i found it in the background and open another one for it

private void Graph_Load(object sender, EventArgs e)
    {
       System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer();

        timer1.Interval = 60000;//1 minutes
        timer1.Tick += new System.EventHandler(Timer1_Tick);
        timer1.Start();
    } 

 private void Timer1_Tick(object sender, EventArgs e)
    {
        //do whatever you want 
        RefreshMyForm();
    }


    private void RefreshMyForm()
    {
        this.Close();

        Graph1 graph = new Graph1();
        graph.Show();


    }

start refresh is what i looking for

1 Answers1

0

All you have to do is to change RefreshMyForm() to Refresh(); and clear function RefreshMyForm().

    private void Graph_Load(object sender, EventArgs e)
    {
        {
            System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer();

            label1.Text = DateTime.Now.ToString("HH:mm:ss");

            timer1.Interval = 60000;//1 minutes
            timer1.Tick += new System.EventHandler(Timer1_Tick);
            timer1.Start();
        }
    }

    private void Timer1_Tick(object sender, EventArgs e)
    {
        label1.Text = DateTime.Now.ToString("HH:mm:ss");
        Refresh(); // OR Invalidate(); OR Update();
    }     

Here label1 is simple watch to see how form refreshed every minute

E.Georgiev
  • 72
  • 2
  • your code refresh the label only not that form what i'm looking for is howa to refresh that form with the timer and close it and open it agyen to loud the data –  Feb 14 '19 at 09:18