1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

move a panel from one form to another

Discussion in 'Questions (Windows Mobile)' started by pochero, Feb 6, 2009.

  1. pochero

    pochero Member Licensed User

    Is it possible to move a panel (with its components), from one form to another? Thank you.
  2. digitaldon37

    digitaldon37 Active Member Licensed User

    You might try the ChangeParent command

    Changes a control parent.
    Using ChangeParent you can move a control from one form to another.
    Syntax: ChangeParent (Control As Control, Parent As Control)
    Control - The name of the control that will be moved.
    Parent - The new parent for the control.

    Sub App_Start
    flb.ChangeParent("Button2","Form2") 'Moves Button2 to Form2.
    End Sub
  3. pochero

    pochero Member Licensed User

    Thank you, but it doesn't work for me with a panel, i get an error:


    Error description:
    El objeto de tipo 'Dbasic.EnhancedControls.CEnhancedPanel' no puede convertirse en el tipo 'System.Windows.Forms.Form'.

    It can't convert a panel object to a form object.
  4. klaus

    klaus Expert Licensed User

    You must:
    - load the FormLib library
    - Add a FormLib object for example flb
    - declare the the flb FormLib object with
    - Add somewhere in your, depending on how and when you want to move the panel with.

    Attached a very small example, it shows you that you can move a panel from Form1 to Form2 and also backwards.

    Best regards.


    Attached Files:

  5. pochero

    pochero Member Licensed User

    Thank you very much, it works.
  6. pochero

    pochero Member Licensed User

    I have a problem, when the panel is moved, it is at background of all controls of the destiny form. I try panel.bringToFront but has no effect.
    I want the moved panel is in foreground

    In your example try to add a buttonX in the form2, when you move the panel, the buttonX appears on top of the panel's button.

    Thank you
  7. klaus

    klaus Expert Licensed User

    It works !

    Try the example below.

    I added Panel1.BringToFoint here:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Sub [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]btnMovePanel_Click[/SIZE][/FONT]
    2][FONT=Courier New]flb.ChangeParent([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Panel1"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Form2"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
    2][FONT=Courier New]Panel1.BringToFront[/FONT][/SIZE]
    FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
    I added Button1 on Form2 and the panel hides it. You can move the panel down and up to see and hide this button.

    Notice that Button2 belongs to Panel1, this just to show that the panel is moved with it's controls.

    Best regards.
  8. pochero

    pochero Member Licensed User

    Thank you very much, I create the objects dynamically, and i did the "bringToFront" before creating the statics objects. Thanks again.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice