c# - I want to make a panel have a thick border. Can I set this somehow? -
I want to make a panel is a thick limit, can I set it in some way?
PS, I am using C #. V.S. 2008.
Jim,
I have created a user control and have a ParentControlDesigner As I told in my comment that what you are saying for this is not the right solution. But this should be a good starting point. Oh, any FYI, I've got this also a customizable border color. I got inspiration from another SO post to pursue this ... It was expected by me. Upon setting the border size, PerformLayout is called to rearrange things correctly. Override of displayRectangle and on-race setDisplayRectLocation is the proper replacement of the hair controls due to the call. Also, "0,0" is not compared to hair controls when the highest in the upper left ... unless the threshold width is set to 0 ... and the OnPaint provides a custom image of the boundary.
Welcome again! Custom Controls Parents are difficult, but not impossible.
[designer (typef (parent controller designer)] public partial category custompanel: UserControl {Color _borderColor = Color.blue; Int _borderWidth = 5; Public Int Borderwidth {Get {Returns _ Border with; } Set {_borderWidth = value; Invalid (); PerformLayout (); }} Public CustomPanel () {InitializeComponent (); } Public override retelling displays (Return to new reception) (Bidder Wide, _binder Width, Bounds with - _ Bidder Wide * 2, Bounce Highlight - _Birmer with * 2); }} Public color border collar {get {return_borderColor; } Set {_borderColor = value; Invalid (); }} Get new public border style border style {get_borderWidth == 0? Border style. Non: Border Style. FixedSingle; } Set {}} Protected Override Zero Onpaint (PaintAventErgus E) {base.OnPaintBackground (e); If (this.BorderStyle == BorderStyle.FixedSingle) {using (pen p = new pen (_borderColor, _borderWidth)) {rectangle r = clientrectengle; // Now for the mystic stuff ... // To get the corrected rectangle, we actually adjust the rectangle as the .net centers in the form of a line based on the width of the rectangle of // Will happen. R. Inflett (-content to INT32 (_bidder withth / 2.0 + .5), -content.OINT 32 (_borderWidth / 2.0 + .5)); E.Graphics.DrawRectangle (P, R); }}} Safe Override Zero OnResize (EventArgs e) {base.OnResize (e); SetDisplayRectLocation (_borderWidth, _borderWidth); }}
Comments
Post a Comment