开发者

How to paint on Form at Design Time?

开发者 https://www.devze.com 2023-02-25 04:52 出处:网络
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 c开发者_开发知识库alled and th

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 c开发者_开发知识库alled 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消