vb6中的picturebox控件的autoredraw属性的vb.net做法
www.dimcax.com
vb6中的picturebox控件的autoredraw属性的vb.net做法
vb6中的picturebox控件的有autoredraw属性,设置为true,则窗口最小化或被覆盖后重新打开窗口,原来的图形还在(使用line等函数画的图形),但vb.net没有了这个属性,为此烦了好久,msdn上也没有找到明确的代用方法,上星期去书店翻了翻,终于明白怎么会事.
private sub form1_load(byval sender as object, byval e as system.eventargs) handles mybase.load
dim bmp as bitmap
dim gra as graphics
dim pen as new pen(color.white)
bmp = new bitmap(picturebox1.width, picturebox1.height)
gra = graphics.fromimage(bmp)
dim dia as single = math.min(picturebox1.height, picturebox1.width) * 0.5!
gra.drawarc(pen, (picturebox1.width - dia) / 2.0!, (picturebox1.height - dia) / 2.0!, dia, dia, 0, 360)
gra.drawline(pen, 0, 0, picturebox1.width / 2.0!, picturebox1.height / 2.0!)
picturebox1.image = bmp
end sub
上面代码画的图形在最小化后重新打开图形还在,下面的则没有了.
private sub picturebox1_doubleclick(byval sender as object, byval e as system.eventargs) handles picturebox1.doubleclick
dim gra as graphics = picturebox1.creategraphics()
dim pen as new pen(color.magenta)
dim dia as single = math.min(picturebox1.height, picturebox1.width) * 0.5!
gra.drawrectangle(pen, (picturebox1.width - dia) / 2.0!, (picturebox1.height - dia) / 2.0!, dia, dia)
end sub