Monday, 15 February 2010

vb.net - Trying to remove a previously created border in Visual Basic -



vb.net - Trying to remove a previously created border in Visual Basic -

i have code:

sub drawborder() dim objgraphics graphics objgraphics = me.creategraphics objgraphics.clear(system.drawing.systemcolors.control) objgraphics.drawrectangle(system.drawing.pens.red, picshowpicture.left - 1, picshowpicture.top - 1, picshowpicture.width + 1, picshowpicture.height + 1) objgraphics.dispose() borderstatus.text = "border drawn" end sub

and draws border around picturebox. want utilize button remove 1 time again can't seem create work.

don't utilize creategraphics, that's temporary drawing erased when minimize form or move off screen, etc.

try holding variable , invalidate form:

private _showborder boolean public sub new() initializecomponent() me.doublebuffered = true end sub private sub button1_click(sender object, e eventargs) handles button1.click _showborder = not _showborder me.invalidate() end sub protected overrides sub onpaint(e painteventargs) e.graphics.clear(me.backcolor) if _showborder e.graphics.drawrectangle(pens.red, picturebox1.left - 1, picturebox1.top - 1, picturebox1.width + 1, picturebox1.height + 1) end if mybase.onpaint(e) end sub

vb.net winforms border

No comments:

Post a Comment