读书人

自定义控件重绘有关问题

发布时间: 2013-08-06 16:47:25 作者: rapoo

自定义控件重绘问题!
protected override void OnDraw()
{
Image broculoImage = global::Test.Properties.Resources.Building;
int width = broculoImage.Size.Width;
int height = broculoImage.Size.Height;
Rectangle big = new Rectangle(0, 0, 64, 64);
this.graphics.ScaleTransform(this.m_Scale, this.m_Scale, MatrixOrder.Prepend);
this.graphics.DrawImage(broculoImage, big);
}
代码如上,我自定义了一个控件,然后在鼠标点击的事件中实现缩小一半的功能,但是出现下图的问题,原来的依然存在,怎么处理?求指导!
自定义控件重绘有关问题
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
this.m_Scale = 0.5F;
this.Invalidate();
}
[解决办法]
this.graphics.Clear(this.BackColor);

读书人网 >C#

热点推荐