Good text to the top concern me to collect the article Xu Chun
Follow-1
Fans-30 0
User controls:
Use layouts to consolidate multiple controls into a single control, modify them to suit your needs, and modify all controls and control properties within a user control
To create the add control dynamically:
1 // Defining control Types 2 New Button (); 3 // Control Name ... such as attributes, can also be directly bound to various events 4 "mybutton" + i.tostring (); 5 // add to the form this can be replaced with the container control 6this . Controls.Add (BTN);
Timer Control:
Code Creation Binding Event
1System.Timers.Timer T =NewSystem.Timers.Timer (10000);//instantiate the Timer class, set a time interval of 10000 milliseconds;2t.elapsed + =NewSystem.Timers.ElapsedEventHandler (theout);//execution of events at time of arrival;3T.autoreset =true;//Whether the setting is executed once (false) or always executed (true);4t.enabled =true;//whether to execute the System.Timers.Timer.Elapsed event;5 6 Public voidTheout (Objectsource, System.Timers.ElapsedEventArgs e)7 { 8MessageBox.Show ("ok!"); 9}
Design interface
1. Drag the timer to the interface, set the attribute value, time interval and so on;
2. In the event, double-click the automatic generation method such as Theout;
3. Call the method, Timer.start (), Timer.stop () in the button event to invoke, and so on.
WinForm user controls, dynamically creating add controls, Timer controls-December 12, 2016