Write himself controls (on) authors used c #: willsound www.ASPCool.com Time: 2002-7-11 17:23:41 Views: 7629
WillSound (willsound@163.com) I usually prefer to use delphi, little life, I like delphi, usually develop (at least now) multi-use Delphi, but I am not afraid of a master joke, I have not written control with Delphi, although the principle I know, but I always feel that I don't know how to start: L but since I have contacted C #, which is the beautiful posture (code style), the wind is not indulging, and it is better than Delphi. I touched me deep. After a period of practice, I found that in development controls and components (other aspects, I don't dare to decompress), and it is simple to be refreshing. How to try it. J is right, my development platform is the formal version of Windows 2000 Server .vs.NET official version, it is followed by the Form Control Button multiplied, can achieve gradient background, implement the pattern And texture fill text. Ok, we started to start a VS.NET 2 in the File menu, point to New, then select Project to open the New Project dialog. Select the "Windows Control Library" project template from the C # Projects list, and then type lineargradientButtonLib in the Name box, then click OK. 3 In the Solution Explorer, right-click UserControl1.cs and select View Code from the shortcut menu. 4 Locate the Class Statement Public Class UserControl1, change UserControl1 to LinearGradientButton to change the name of the component. Find constructor public userControl1 (), change it to public lineargradientButton (). 5 Change the control from System.Windows.Forms.userControl to System.Windows.Forms.Button in the Class statement. This allows inherited controls to inherit all functions of the Button control. 6 In the Solution Explorer, click UserControl1.cs, and in the Properties window, change the fileName property to lineargradientButton.cs. Ok, go to the work now, let's take a fall, the following work is to we The control is added attribute. Drink water, continue! Plus the name space for use system.drawing.drawing2d; 1 Locate the Class statement.
Type the following code: Private color frocolor; // Gradient Private Color BackColor; // Gradient Background Color Private Bool ISUSEFLOAT; // Whether to use angle transformation private float angle; // Place angle Private lineargradientMode Mode ; // Set the angle of gradient, private hatchStyle HatchStyle; // Set the text's padding pattern private bool iSuseStyle; / / Set whether it is the private domain that we need to use the pattern fill pattern, starting below for each private domain Do their corresponding properties. Below below, write the following code: [Description ("Set button gradient foreground color"), category ("Appearance")] public color frontcolor {get {return frocolor;} set { Frocolor = value;}} [Description "), category (" APPEARANCE ")] public color backroundcolor {get {return backcolor;} set {backcolor = value;}} [defaultValue (false) Description ("Set whether or not manual setting angle")] public bool usefloat {get {return isusefloat;} set {isusefloat = value;}} [defaultValue SE), Description ("Set whether to use the pattern fill text")] Public Bool Uptionyle {get {return isusesStyle;} set {iSuseStyle = value;}} [defaultValue (0), Description ("Defines the angle of the gradient direction, The degree is measured from the X axis. "), Category (" Appearance ")] public float angle {get {return = value;}} [defaultValue (0), Description (" When USEFLOAT is set to FALSE, the gradient direction is set.