Dot NET winform control development (1) write the simplest Control

Source: Internet
Author: User
Tags dot net

Use vs to create two projects (customcontrolsample, testcontrol). The project types are class libraries (Not underpants !!!), Windows applications.

1 using system. Windows. forms;
2 using system. drawing;
3
4 namespace customcontrolsample
5 {
6 public class firstcontrol: Control
7 {
8 private int simplefield;
9
10 public int simpleproperty
11 {
12 get {return simplefield ;}
13 set {simplefield = value ;}
14}
15
16 protected override void onpaint (painteventargs E)
17 {
18 base. onpaint (E );
19 E. Graphics. drawrectangle (pens. Red, new rectangle (point. Empty, new size (width-1, height-1 )));
20}
21}
22}

There is only one Property Control !!!

Drag to Windows form:

In the Property browser, you can see the unique property of the control:

A simple dot net winform control is ready.
The end.

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: info-contact@alibabacloud.com 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.