We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Master save on a mdi parent

vlvawter
vlvawter asked
on
Medium Priority
290 Views
Last Modified: 2008-02-26
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?
Comment
Watch Question

Brian CroweDatabase Engineer
CERTIFIED EXPERT
Top Expert 2005

Commented:
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

Author

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?
Database Engineer
CERTIFIED EXPERT
Top Expert 2005
Commented:
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.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
I simply added a toolstrip on frmChild with a save icon.  The code behind that is a SaveAll.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.