NET Framework Provides you with the ability to develop and implement new controls . In addition to the common user controls , Now you'll find , You can write custom controls that can perform your own drawing , You can even extend the functionality of existing controls through inheritance can . Determining what type of control to create can be a lot of work . This section focuses on the differences between various types of inheritable controls , Also provide considerations about the type of project you choose .

1、 Component Class

Component Class You can get it from any existing Windows Form controls inherit to produce new controls . This method allows you to keep Windows All the inherent functions of form controls , And then by adding custom attributes 、 Methods or other functions extend this inherent function . for example , You can create one from  TextBox  Inherited controls , The control accepts only numbers and automatically converts input to values . Such controls may contain validation code , This code is called whenever the text in the text box changes , in addition , Control may also have an additional “ value ” attribute . In some controls , You can also override the  OnPaint  Method to add a custom appearance to the graphical interface of the control .

Inherit when Windows Form control :

  • Most of the required features are already in line with the existing Windows Form controls are the same .
  • No need to customize graphics interface , Or want to design a new graphic front end for existing controls .

2、User Control

use The user control is encapsulated in a common container Windows A collection of form controls . This container contains information related to each Windows All the inherent functions associated with form controls , Allows you to selectively expose and bind their properties . One example of a user control might be a generated control that displays customer address data in a database . The control may include Several text boxes for displaying fields , A couple of buttons for positioning by recording (Button) Control . Data binding properties can be selectively exposed , The entire control can be packaged and reused between applications .

Use when  UserControl :

  • It's going to take a number of Windows The function of form control composes a reusable unit .

3、 Custom Control

Custom Control It's through  Control  Inherit to create a control completely from scratch .Control  Class provides controls ( For example, events ) All the basic functions needed , But it doesn't provide control specific functions or graphical interfaces . And through the user control or existing Windows Form controls inherit to create controls , By getting from  Control  Class inheritance takes a lot more thought and effort to create controls . Because the author has to be  OnPaint  Event writing code and any function specific code required , But at the same time, it also allows the author to meet his own needs , Flexible custom tuning controls . The clock control is a custom control , It replicates the appearance and operation of an analog clock , Custom drawing will be called to move the clock pointer around , In response to the  Tick  event .

Use when Custom Control:

  • Want to provide a custom graphical representation of the control .
  • You need to implement custom functions that are not available from standard controls .

WinForm in Component Class、User Control And Custom Control The difference and use of more related articles

  1. WPF Medium Generic.xaml, theme as well as custom control

    original text :WPF Medium Generic.xaml, theme as well as custom control stay Visual Studio When creating a custom control in , All controls will be added to /Themes/Generic.xaml. most ...

  2. WinForm in Component Class、User Control And Custom Control The differences and suggestions for the use of

    reference: http://blog.csdn.net/redstonehe/article/details/1536549 .NET Framework Provides you with the ability to develop and implement new controls . except ...

  3. WinForm in Component Class、User Control And Custom Control The difference and use of - turn

    turn http://www.cnblogs.com/jhtchina/archive/2010/11/28/1028591.html NET Framework Provides you with the ability to develop and implement new controls . In addition to common ...

  4. VS in Component Class、User Control And Custom Control The difference between .

    .NET Framework Provides you with the ability to develop and implement new controls . In addition to the common user controls , Now you'll find , You can write custom controls that can perform your own drawing , You can even extend the functionality of existing controls through inheritance . Determine what type of control to create to ...

  5. [ Reprint ] Winform Some of them are easy to use Grid Control

    from Blog Garden  http://www.cnblogs.com/peterzb/archive/2009/05/29/1491781.html 1.DataGridView  .net 2.0 The net that comes with the frame ...

  6. C# WinForm in Label Word wrap resolvent

    stay TableLayoutPannel There are some in it Label If you put Label Of AutoSize Property set to True Words , Words are more than label The length will increase automatically , Until after the word out of the window set to False when , Once arrived ...

  7. C# Thread three in ( combination ProgressBar Study Control.BeginInvoke)

    C# Thread three in ( combination ProgressBar Study Control.BeginInvoke) This article is a continuation of the previous article on Control.BeginInvoke After that , Another example is given to illustrate Cotrol.Begi ...

  8. stay Winform Play videos in the video 【DotNet,C#】

    I have encountered such problems in the project , Is how to Winform Video in . At that time, several ways were investigated , The first is direct use Windows Media Player Components , This is the simplest : The second is to use DirectX Directly in the form or control ...

  9. WinForm in DefWndProc、WndProc And IMessageFilter The difference between

    This article mainly introduces WinForm in DefWndProc.WndProc And IMessageFilter The difference between , A more detailed analysis of WinForm Message processing mechanism of , Friends in need can refer to     Generally speaking ,Win ...

Random recommendation

  1. Learning together jQuery2.0.3 Source code —1. The opening

    write less,do more jQuery Tell us : Awesome code is not only streamlined but also efficient ! 2006 year 1 Month by the Americans John Resig In New York barcamp Released jQuery, It attracts a lot of people from all over the world Ja ...

  2. Use Delphi Send and receive GMail The mail

    GMAIL The port and connection mode of is special :SMTP Port is :456POP3 Port is :995 They all use secure connections (SSL) These pass through Indy The reference code is as follows : object IdConnectionInterc ...

  3. ubuntu14.04 Set the power on brightness

    1 Check the maximum brightness of your system : cd /sys/class/backlight There are different types of graphics cards in laptops -> The brightness adjustment folder name will be different . 2 My is intel_backlight cd intel_b ...

  4. install oracleASM

    problem :oracleasm status Cannot start Solution : [root@localhost ~]# oracleasm statusChecking if ASM is loaded: noCheck ...

  5. MongoDB Copy set learning ( One ): Overview and environment building

    MongoDB Replica set Overview The following pictures are taken from MongoDB Official documents :http://docs.mongodb.org/manual/core/replication-introduction/ Primary ...

  6. shell elements of grammar

    One . Variable 1.linux Case sensitive , Pay attention to the case of variable names . You can add... Before the variable name $ To access the contents of the variable . By using read Command to assign a user entered value to a variable . 2. When you assign a value to a variable , If the string contains spaces , It must be ...

  7. Java GUI+mysql+ Paging query

    1. requirement : Create a student information management database 2. Realize paging query The code is as follows : a) Student entity : /** * @author: Annie * @date:2016 year 6 month 23 Japan * @description: ...

  8. [TCP] Network protocol flow chart

    Before, I couldn't find a similar picture when I talked about the agreement with others , Let's see this time python I found one when I was reading network programming books , Keep a copy of . Clearly see the transmission process of different protocols in different layers !

  9. Kernel debugging artifact SystemTap — Probe points and grammar ( Two )

    a linux trace/probe tool. Official website :https://sourceware.org/systemtap/ Detection point SystemTap The script is mainly composed of probe points and probe point processing functions , Take a look ...

  10. linux The kernel stack

    One : Stack of processes When the kernel creates a process , Creating task_struct At the same time, the corresponding stack will be created for the process . Each process has two stacks , A user stack , In user space , A kernel stack , save It's in kernel space . When a process is running in user space ,c ...