Write himself controls (under) with c # Author: willsound www.ASPCool.com Time: 2002-7-11 17:24:15 Views: 6736
Because our control is to implement background gradient and text filled, the Override Paint event is completed.
In order to complete Override, the following preparations (writing a few events in the Paint event). // Using an angle method As Juanji Heavy painting Button Private Void DrawButtonwithangle (Graphs DBG) {LinearGradientBrush Brush = New LineargradientBrush (New Rectangle (0, 0, this.width, this.height), frocolor, backcolor, angle; dbg.fillRectangle (Brush, 0, 0, this.width, this.height); brush.dispose ();} ASYMPTOTICS redraw Button private void DrawButtonWithMode (Graphics dbg, LinearGradientMode Mode) {LinearGradientBrush brush = new LinearGradientBrush (new Rectangle (0,0, this.Width, this.Height), froColor, backColor, Mode); dbg.FillRectangle ( Brush, 0,0, this.width, this.height); brush.dispose ();} // Heavy painting Button's text (Text), not using the pattern fill the Private Void DrawButtonText (Graphics DBG) {StringFormat Format = New StringFormat (); format.LineAlignment = StringAlignment.Center; format.Alignment = StringAlignment.Center; dbg.DrawString (this.Text, this.Font, new SolidBrush (this.ForeColor), new Rectangle (0,0, this.Width , This.Height), format);} // override DrawButtonText function, so that it can fill the text pattern private void DrawButtonText (Graphics dbg, HatchStyle hs) {StringFormat format = new StringFormat (); format.LineAlignment = StringAlignment.Center; Format.Alignment = StringAlignment.center; dbg.drawstring (this.text, this.font, new hatchbrush (hs, this.forecolor, color.aquamarine), New Rectangle (0, 0, this.width, this.Height), Format);