• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

Master save on a mdi parent

I have a mdi parent (frmParent) and a child (frmChild).  On the child is a tabcontrol with 2 tabs.  On each tab are datasets: tab1 has textboxes bound to ds1 and ds2; tab2 has textboxes bound to ds3 and ds4.

I have no problem with individual save buttons on each tab page to check for changes and then update the database.  My problem is using the Save on frmParent.  I want a "master" save button that will check for all the respective tab pages.

I know how to identify the active child form, e.g., Dim f as Form = me.ActiveMdiChild.  How do I identify programmically what datasets are associated with what tab page?  Somehow I need to cycle through each tab page, check whatever datasets are on it, and update as needed.

Can you help?
0
vlvawter
Asked:
vlvawter
  • 2
  • 2
1 Solution
 
Brian CroweCommented:
dont' try and do the saving within the parent.  Just create a method in the child form that saves all the data on that form.

class frmChild
...
public sub SaveAll()
   'save changes
end sub
0
 
vlvawterAuthor Commented:
Are you saying not to save inside the parent because it is too complicated or because it cannot be done?

Also, if I create a control for frmChild that activates "Save All," is there a way to raise that event from frmParent?
0
 
Brian CroweCommented:
It's bad design.  One of the principles of object-oriented programming and design is encapsulation.  Members (variables) within a class should not be directly manipulated or accessed from outside the class.

You don't need to add a control or raise event (although adding a delegate to take care of this is an option).  Just add the method to your childform.

if typeof(me.activemdichild) is frmchild then
   ctype(me.activemdichild, frmchild).saveall
end if

You could also use reflection to determine if a given child has the "SaveAll" method.
0
 
vlvawterAuthor Commented:
I simply added a toolstrip on frmChild with a save icon.  The code behind that is a SaveAll.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now