简体   繁体   English

覆盖 OnPaint:绘制多个矩形

[英]Overriding OnPaint: Drawing more than one rectangle

Can anyone provide me C# code to fill two rectangles in override onpaint method.Here I'm trying to create a messagebox dialog which has a message title topbar and message text.谁能提供给我 C# 代码来填充覆盖 onpaint 方法中的两个矩形。这里我正在尝试创建一个消息框对话框,其中包含消息标题顶部栏和消息文本。

Call e.Graphics.FillRectangle twice.调用e.Graphics.FillRectangle两次。

Well, there is a short article on MSDN on How to draw a filled rectangle - if you want to draw two rectangles then do that twice!好吧,MSDN 上有一篇关于如何绘制填充矩形的短文——如果你想绘制两个矩形,那就做两次! Note that if you are handling the OnPaint event there is no need to call CreateGraphics as a Graphics object is passed to you in the event arguments.请注意,如果您正在处理OnPaint事件,则无需调用CreateGraphics ,因为在事件 arguments 中将Graphics object 传递给您。

However it sounds like you shouldn't need to do any of this.但是,听起来您不需要做任何这些。 You should be able to do what you are asking with standard forms and controls (or possibly just the MessageBox class)您应该能够使用标准 forms 和控件(或者可能只是MessageBox类)来完成您所要求的事情

Can you elaborate slightly more on what it is you need to do in your dialog?您能否详细说明您需要在对话中做什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM