日期:2014-05-18 浏览次数:21045 次
protected override void OnPaintBackground(PaintEventArgs pevent)//OnPaintBackground是我测试的,具体你用时可能就不是pevent,可能是 g,那就直接用 g.FillRectangle
{
base.OnPaintBackground(pevent);//我测试时是用重载PictrueBox,这个是填充原本的背景。
if (this.Image != null)
{
GraphicsUnit gUnit = GraphicsUnit.Pixel;
RectangleF rect = this.Image.GetBounds(ref gUnit);//获取图片的矩形大小,
pevent.Graphics.FillRectangle(Brushes.Red, rect.Left - 2, rect.Top + 2, rect.Width, rect.Height);//Brushes.Red是我测试时用红色来显示。
}
}
------解决方案--------------------
mark