best way of updating grid in other form

H

Harry Hudini

Hi,

I have two forms, frmMain and frmAdd. frmMain has a grid which shows
records. The grid is populated by hand from a datatable so that i can do
some manipulation to the data. frmMain has a Sub in it that fills the
datagrid and does the manipulation.

When I add a record using frmAdd, I want to update the grid so that when the
frmAdd form closes the user is presented with an up to date list of records.

Now i can see two ways of doing this;

1) Make the sub in frmMain a public sub, and call it from frmAdd before
closing frmAdd.

2) use a public variable to store a flag showing whether an update of the
grid is needed. When the user closes frmAdd the routine that originally
displayed frmAdd then checks the variable and updates the grid.

I prefer method #1, though it feels like a waste to create a new instance of
frmMain just so that i can call a public sub of it, then to close it again.

Method 2 strikes me as a bit messy, though the only real issue is that each
time frmAdd is shown, it wouild have to be shown as modal.

Any thoughts on the proper way of doing this ?



--
________________________________________________
ADSSupport.net
http://www.adssupport.net
Dedicated free Active Directory ServicesT support

email: oliver.marshall@[email protected]
 
G

Guest

You can also use Events and Delegates. Create an event in frmAdd and raise that event when something is added. Then on frmMain you register for the events from frmAdd and when the event is raised you update your grid from frmMain.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top