简体   繁体   中英

how to activate form1 on closing of form2 while form1 remains open on opening of form2

I work on clinic application in vb.net.I have tow forms frmMain and second one is frmPatient. while my application starts frmmain is load on MdiForm by default. I have data grid on frmmain form which shows patient record in grid. while open patient basic data the main form still opens and user enter the basic data of patient and click on save. after save whe patient form will close i want to update the grid of main form with the newly inserted record. But i dont know how to do it. any one plz help me to do it. I use frmMain.Activate or frmMain.Refresh on frmPatient deactivate,FormClose and formClosing events but nothing works for me. how can i activate my frmMain form on closing of frmPatient form.

I dont want to use frmMain.Show or frmMain.showDialouge becasu they willl create new instances of frmmain form.

Below is my code in which i try to load the data on FrmMain grid while closing frmPatient.here i call the method MyrefeshMethod of frmMain form which load the data on grid. here Me.txtptId.Text have value which is added recently in database from frmPateint form.

Dim dts As New DataSet
dts = objCode.ptInfoGetById(Me.txtptId.Text)
FrmMain.MyrefeshMethod(dts)

but it does not load the new record on screen. what can i do for it.

I would implement a broadcast system for events, I've done it in similar systems.

Jerry Miller has a great blog about it.

By this design, I send events from one from to another.

http://codebetter.com/jeremymiller/2009/07/22/braindump-on-the-event-aggregator-pattern/ http://codebetter.com/jeremymiller/2009/07/24/how-im-using-the-event-aggregator-pattern-in-storyteller/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM