Override OnPaint

If I override OnPaint and draw a square on the control, how do I get this e.graphics.draw ... so that it appears when I view it in the designer?

+3
source share
2 answers

http://msdn.microsoft.com/en-us/magazine/cc164048.aspx

http://msdn.microsoft.com/en-us/magazine/cc164145.aspx

While you can manually register with Control.OnPaint to add your design time user interface, you will find that overriding OnPaintAdornments is the best option because it is called only after the development time / runtime user interface is painted, allowing you to overlay the icing on the cake (see Fig. 20). Just adding DesignerAttribute to the ClockControl class completes the association: Copy code

[Designer (TypeOf (ClockControlDesigner))] class ClockControl: Control {...}

+6
source

If you are trying to draw a focus rectangle for your control and whether it will be visible when manipulating your control after adding it to the form, then the Gaijin42 approach should work.

, ,...

  • OnPaint , OnPaint, ( ).

  • Paint , , ( , VS2005):

    , . . OnPaint .. .

    - . VS2005 , , .

+1

Source: https://habr.com/ru/post/1706246/