[Gambas-user] Reparenting a form on a tabstrip....

timothy timothy.marshal-nichols at ...247...
Mon Feb 12 09:56:27 CET 2007



> -----Original Message-----
> From: gambas-user-bounces at lists.sourceforge.net [mailto:gambas-user-
> bounces at lists.sourceforge.net] On Behalf Of sbungay
> Sent: Saturday, 10 February 2007 03:26 AM
> To: mailing list for gambas users
> Subject: Re: [Gambas-user] Reparenting a form on a tabstrip....
> 
>    I see. I would never have guessed to set the tab index first, like
> the data bound controls, I was once again expecting to explicitly
point
> one object to another :/. I'll have to watch that.
> 
> Steve :)
> 
> 
> Benoit Minisini wrote:
> > On Friday 09 February 2007 23:00, Daniel Campos wrote:
> >
> >>Not a bad idea, I think nobody thought in it before...
> >
> >
> > This is what gb.form.mdi does!
> >
> >
> >>2007/2/9, sbungay <sbungay at ...981...>:
> >>
> >>>   Goal: To reparent an instance of a form on the tabstrip index of
my
> >>>choice. The code snippet is below.
> >>>
> >>>   ' Gambas class file
> >>>   PRIVATE mForm1 AS Form
> >>>
> >>>   Private SUB Form2_Open()
> >>>     mForm1 = NEW Form1
> >>>
> >>>     With mForm1
> >>>          .Reparent(TabStrip1[1]) ' This will give
> >>>                                  ' Invalid Use of Virtual Class
> >>>          .Reparent(TabStrip1)    ' This works fine but the form
> >>>                                  ' Only appears on the first tab.
> >>>     End With
> >>>   END
> >>>
> >>>
> >>>   This is kind of (but not exactly) like what I would do if I
created
> >>>an activex control (now I have to wash my hands) and hosted it on a
> form
> >>>in the container of my choosing.
> >>>
> >>>Steve.
> >>>
> >
> >
> > You must set the TabStrip index before doing the reparenting.
> >
> > Regards,
> >
> 


In one of my apps I have a number of forms. I then load one of them into
a ScrollView container on a main form based upon what the user select
from a ComboBox. Here is the code that clears the previous form and
loads the new selection.

' Show form based upon item selected in ComboBox
PRIVATE SUB ShowDemo()
  DIM ctrl AS Control
  DIM oldForm AS Form
  DIM newForm AS Form
  ' Close any previous form
  FOR EACH ctrl IN ScrollViewWindow.Children
    oldForm = ctrl
    oldForm.Close()
  NEXT
  ' Create a new form
  SELECT CASE ComboBoxWindows.Index
    CASE 0 ' Add, Delete and Find items
      newForm = NEW FormAddDelete(ScrollViewWindow)
    CASE 1 ' Auto Add
      newForm = NEW FormAutoAdd(ScrollViewWindow)
    CASE 2 ' Sorting
      newForm = NEW FormSorting(ScrollViewWindow)
    CASE 3 ' Save and Open Lists
      newForm = NEW FormSave(ScrollViewWindow)
    CASE 4 ' Fonts
      newForm = NEW FormFonts(ScrollViewWindow)
    CASE 5 ' Drag and Drop
      newForm = NEW FormDragAndDrop(ScrollViewWindow)
  END SELECT
  ' Display the new form
  newForm.Move(0, 0)
  newForm.Show()
END

Of course, as Benoit says, you could use a Workspace from gb.form.mdi

Thanks

8-{)} Timothy Marshal-Nichols
<mailto: timothy.marshal-nichols at ...247...>







More information about the User mailing list