This bit:
System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer();
timer1.Interval=300000;
timer1.Tick += new System.EventHandler(timer1_Tick);
timer1.Start();
Needs to be inside a method, probably the Form.Shown event handler would be best.
Your code shows it outside any method, and that is not allowed as it can't be executed!
To add an Event handler, open the Form in Design View (the display where you add controls and so forth to the Form), highlight the Form, and select "Events" in the properties window (it looks like a little lightning bolt on the Properties toolbar). Scroll down to "Shown" and double click it. That will add the handler and take you to the method to edit it.