reducing the size of the selection box around a winforms custom control
I have a custom control based on the label control. My question is how do I change th开发者_如何学Pythone selection box size around this custom control when a user selects it while in design mode. The need is the box is too large I need to make it smaller.
Also AutoSize set to true will not work in my case, the selection box is still too big.
You would have to create a designer based on ControlDesigner
for your control then use the DrawFocusRectangle
method in the OnPaintAdornments
event.
ControlDesigner Class - Extends the design mode behavior of a Control at http://msdn.microsoft.com/en-us/library/system.windows.forms.design.controldesigner.aspx.
Extending Design-Time Support at http://msdn.microsoft.com/en-us/library/37899azc.aspx
ControlDesigner.OnPaintAdornments Method at http://msdn.microsoft.com/en-us/library/system.windows.forms.design.controldesigner.onpaintadornments(VS.80).aspx
ControlPaint.DrawFocusRectangle Method at http://msdn.microsoft.com/en-us/library/system.windows.forms.controlpaint.drawfocusrectangle.aspx.
The selection box in the designer is (and must be) dependent upon the size of your control. If you want to make it smaller, your control must be smaller. There is no way to control its size or position manually.
精彩评论