adding controls from other forms to main form 
Author Message
 adding controls from other forms to main form

Hello all!

 My project requires me to display several forms, depending upon
selected options in a listbox. I have 5 options in the listbox
for each option a form is showed. Each form has different controls
which differ greatly from one form to another.

I'd like to keep one form, and as I go along the options load
and unload the controls which correspond to a particular form.
Sort of the install type application program where users can go
back and forth between options.

I tried several approaches from loading the form, setting the
control's form to newly created controls and making them visible to
the displayed form. none worked.

Has anyone tried this? Any info/advice would be appreciated, thanks.

-Jm



Fri, 21 Jul 2000 03:00:00 GMT  
 adding controls from other forms to main form

Hi, Jesus:

Try this, for me it works fine.

Put a PictureBox array control (so many pictures as different "steps" you
need), I recommend you to start from Index 1. All pictures with the same
size: the complete form size, minus a little height for command buttons.
Paste each control in the appropiate PictureBox. Use a local variable to
store current "step". In the bottom of the form put, from left to right: A
"Previous" command button, a "Next" command button with a "End" command
button behind, and a "Cancel" command button

Here's the sample code:

Option Explicit
Dim m_iCurrentStep As Integer

Private Sub ShowCurrentStepPicture()
    Dim iPicture As Integer
    For iPicture = 1 to Picture1.Count
        If iPicture = m_iCurrentStep Then
            Picture1(iPicture).Visible = True
        Else
            Picture1(iPicture).Visible = False
        End If
    Next iPicture
End Sub

Private Sub Form_Load()
    m_iCurrentStep=1
    CommandNext.Enabled = True
    CommandPrevious.Enabled = False
    CommandNext.Visible = True
    CommandEnd.Visible = False
    ShowCurrentStepPicture
End Sub

Private Sub CommandNext_Click()
    Dim bOK As Boolean
    bOK = True
    Select Case m_iCurrentStep
        'Make validation routines for each step and change value of bOK
    End Select
    If bOK Then
        m_iCurrentStep = m_iCurrentStep + 1
        ShowCurrentStepPicture
        If m_iCurrentStep = Picture1.Count Then
            CommandNext.Visible = False
            CommandEnd.Visible = True
        End If
        CommandPrevious.Enabled = True
    Endif
End Sub

Private Sub CommandPrevious_Click()
        m_iCurrentStep = m_iCurrentStep - 1
        CommandEnd.Visible = False
        CommandNext.Visible = True
        If m_iCurrentStep = 1 Then
            CommandPrevious.Enabled = False
        Else
            CommandPrevious.Enabled = True
        End If
 End Sub

Private Sub CommandEnd_Click()
    'Save data and unload form
    'Proper operations for saving user's input
    Unload Me
End Sub

Private Sub CommandCancel_Click()
    Unload Me
End Sub

Hope I helped you,

    Adrian

P.D.: I see your surname looks spanish. ?Have you noticed the existing of
microsoft.public.es.vb? There is a lot of spanish talking people.

Quote:

>Hello all!

> My project requires me to display several forms, depending upon
>selected options in a listbox. I have 5 options in the listbox
>for each option a form is showed. Each form has different controls
>which differ greatly from one form to another.

>I'd like to keep one form, and as I go along the options load
>and unload the controls which correspond to a particular form.
>Sort of the install type application program where users can go
>back and forth between options.

>I tried several approaches from loading the form, setting the
>control's form to newly created controls and making them visible to
>the displayed form. none worked.

>Has anyone tried this? Any info/advice would be appreciated, thanks.

>-Jm



Sat, 22 Jul 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. maximize child form display multiple tool box controls on main form

2. Problem showing a Splash Form and then a Main Form (The Main form does not get control.)

3. changing stuff in your main form from another form

4. Unhandled exception in system.windows.forms.dll (in my main form) - argh

5. Help altering main form from other forms

6. how to change properties of the main form from a another form

7. create main form and Sub Form

8. Forms on top of Main Form

9. VB3: modal form gets hidden by main MDI form in Win98

10. How to auto size the main form/ MDI form

11. create Main Form Sub form in VB6

12. How to switch Main form to other form?

 

 
Powered by phpBB® Forum Software