WinForm user controls, dynamically creating add controls, Timer controls-December 12, 2016

Source: Internet
Author: User

Good text to the top concern me to collect the article Xu Chun
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.