
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