Mdi child form


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Mdi child form

Hybrid View

  1. #1
    Join Date
    Aug 2004
    Posts
    54

    Question Mdi child form

    Hi,
    I do have a MDI form with menu bar containing New and Svae buttons, also I do have a MDI Child form with several control. How can I be able to load the same MDI Child form everytime the user click New button, and also save the active form once he click Save button?
    Thank you,
    Moe.

  2. #2
    Join Date
    Jan 2004
    Location
    Alexandria, VA
    Posts
    392
    Okay, I'm going to make some assumptions here:

    1) You want to reuse the same child form
    2) Your child form is called MyChildForm

    First: Create a Public Sub (or Function) in your child form called "SaveForm"

    You can keep a reference to your form in a variable (we'll call it "frmChild") The code in your MDI parent form would look something like this:

    Code:
    Dim frmChild As Form
    
    Private Sub cmdNew_Click()
    
        frmChild.Visible = True
        
    End Sub
    
    Private Sub cmdSave_Click()
    
        frmChild.SaveForm
        frmChild.Visible = False
        
    End Sub
    
    Private Sub Form_Load()
    
        Set frmChild = MyChildForm
        Load frmChild
        
    End Sub
    Bob Rouse
    Dimension Data

  3. #3
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    I think Moe wants to have more than one child form of the same type. Please correct me if I am wrong. To create a new form of type frmChild put this in the New menu Click event:

    dim frx as frmChild
    set frx = new frmChild
    frx.Show

    To save the current active frmChild, put this in the Save menu Click event:

    if myMDIform.ActiveForm is nothing then exit sub
    if not typeof myMDIform.ActiveForm is frmChild then exit sub
    myMDIform.ActiveForm.Save

    Marco

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center