vb.net - Show single instance of form in other project -
i have multiproject solution 1 project "main", startup project.
project starting forms in other projects referenced in startup project.
problem can start forms instances this:
dim ka new otherproject.frm_thatform ka .bringtofront() .show(me) end
that opens new "thatform" every time to start "thatform" single instance every time , "thatform" comes front.
how that?
i try this:
dim ka otherproject.frm_thatform ka .bringtofront() .show(me) end
... don't work (object reference not set instance of object).
the trick not dim form , use shared object.
otherproject.frm_thatform.show() otherproject.frm_thatform.bringtofront()
as long dont close window can call same way dimmed object.
instead of ka type otherproject.frm_thatform
as close window loose in it.
edit: apparently works forms inside project. bad :(
what need instead keep list of forms inside main project.
make sure give form name, , when click button open form loop through list find set name.
something this:
private formlist new list(of form) private sub button2_click(sender system.object, e system.eventargs) handles button2.click dim theform form = nothing each f form in formlist if f.name = "selected form name" theform = f end if next if theform nothing theform = new otherproject.frm_thatform() theform.name = "selected form name" formlist.add(theform) end if end sub
Comments
Post a Comment