Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to paint on Form at Design Time?

Tags:

c#

.net

winforms

If I have a UserControl and override OnPaint I can do what I want there and when I add that UserControl to a Form in designer in Visual Studio 2010 the OnPaint method is called and the user control is painted and viewed in the designer as I want.

The question is can I do that with a Form not with an UserControl? How can I draw on Form that designer shows them?


1 Answers

The designer creates your form's base class; it doesn't create your form itself.
Any code in your form class itself will not run in the designer.

You need to make a separate base class that inherits Form and paints itself.
You will then see the painting in the designer of any form that inherits the base class.

like image 102
SLaks Avatar answered Oct 27 '25 03:10

SLaks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!