Passing parameters between two forms in VB.Net -


i have 5 forms in application. i'm building 6th form - frmsummary however, i'd able access forms. in frmsummary planning add datagridview, i'll displaying data related form. i'm thinking should either create global variable such

dim frmname string 

in each form have cmdsummary button on click_event, like

frmname ="customerinfo" 

currently way application set hve mdiform , within it, each form child on opening new forms like...

private sub cmdsummary_click(sender object, e eventargs) handles cmdsummary.click     dim newmdichild new frmclienteligibilityreferral()      frmname = "customerinfo" --since comeing frmcustomerinfo     newmdichild.mdiparent = mdiform1     newmdichild.show()     mdiform1.show()  end sub 

so on opening new form. question how can pass parameter form frmsummary....here's i'm trying accomplish....

private sub frmsummary_load(sender object, e eventargs) handles me.load      me.mdiparent = mdiform1      initializecomponent()  'here want call function load datagridview(with g_frmname)see below...     call loaddatagrid(frmname) end sub 

is smart idea? or should i/can directly call function previous form? trying see if i'm on right track, if not, how can in sound way?

if there 1 frmsummary, make singleton.

in frmsummary, put following code:

private shared _instance frmsummary  private sub new()     ' call required designer.     initializecomponent()     ' add initialization after initializecomponent() call. end sub  public shared function getinstance() frmsummary     if _instance nothing         _instance = new frmsummary()     end if     return _instance end function  public sub putdataingrid(data object)     me.datagridview1.' put data in end sub 

and access other forms this

dim myfrmsummary = frmsummary.getinstance() myfrmsummary.putdataingrid(mydata) 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -