vb.net - Remove the windows form controls on exit -


i'm adding form controls on loading form manually:

me.fieldi = new textbox() me.fieldi.location = new system.drawing.point(50, 10) me.fieldi.name = "fieldi" me.fieldi.size = new system.drawing.size(40, 20) me.fieldi.tabindex = 5 me.conversion.controls.add(me.fieldi) [..] 

when close form window , reopen it, control still there (with old .text content , because textbox in case).

i remove controls have been created while form loading on form close event, prevent doubling elements on form.

how can achieve this?

edit

form closing code looks following (just showing main form back):

private sub form1(byval sender system.object, byval e system.eventargs) handles me.formclosing     main.show() end sub 

the problem here form not being disposed, when open again controls still there last time opened.

try following:

using frm = new subform()   frm.showdialog() end using 

the variable frm disposed after using.

also...

you can provide feedback dialog, check whether form successful or not. example:

dim frm new subform() if frm.showdialog = dialogresult.ok   'yay! else   'something failed end if 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -