组件和用户控件中的C#:OnPaintBackground [英] C#:OnPaintBackground in Component and User Control

查看:666
本文介绍了组件和用户控件中的C#:OnPaintBackground的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我可以在自定义用户控件中使用 override void OnPaintBackground 吗?我在自定义用户控件中使用此方法的目的是因为我将在绘图区域中将基线(网格)绘制为图像在初始状态,但是此后,当我在其上画线时,我不想再次重新绘制背景(图像).因此,我需要重写OnPaintBackground方法并将其禁用以实现我的目的.我可以在Component中完成,但是如何在自定义用户控件中完成?[confused]

欢迎任何提示.

问候
cocoonwls

Hi all,

Can i use override void OnPaintBackground in custom user control?My purpose to use this method in custom user control is because i will draw the base line (grid) as image in the drawing area at the initiate state, but after that, i don''t want to repaint again the background(image) when i draw some line on it. Thus, i need to override the OnPaintBackground method and disable it to fulfill my purpose. I can done it in Component,but how about in custom user control?[confused]

Any tips are welcome.

regards
cocoonwls

推荐答案

您好,
您可以覆盖OnPaintBackground,到目前为止,我还没有遇到任何问题.如果要绘制默认背景,请确保在覆盖方法中首先调用base.OnPaintBackground.如果您想完全自己绘制背景,请不要调用base.OnPaintBackground.
希望这对

Hi,
you can override OnPaintBackground, I haven''t have any problem with that so far. If you want to draw over default background, be sure to call base.OnPaintBackground as a first thing in your override method. If you want to draw your background completely by yourself, don''t call base.OnPaintBackground at all.
hope this helps


这篇关于组件和用户控件中的C#:OnPaintBackground的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆