如果我重写OnPaint并在控件上绘制一个正方形,那么当我在设计器中预览时,如何让e.graphics.draw …出现? http://msdn.microsoft.com/en-us/magazine/cc164048.aspx http://msdn.microsoft.com/en-us/magazine/cc164145.a
http://msdn.microsoft.com/en-us/magazine/cc164145.aspx
While you could manually register with
Control.OnPaint to add your design
time UI, you’ll find that overriding
OnPaintAdornments is a better option
because it is only called after the
control’s design-time/run-time UI is
painted, letting you put the icing on
the cake (see Figure 20). Simply
adding DesignerAttribute to the
ClockControl class completes the
association: Copy Code[ Designer(typeof(ClockControlDesigner)) ] class ClockControl : Control { … }