Form Management in .net vs 6.0


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Form Management in .net vs 6.0

  1. #1
    TMachi Guest

    Form Management in .net vs 6.0

    I've been chasing my tail on this one... any help here would be great.

    I'm trying to figure out the best way to get two (or more) non-MDI child
    forms to switch between themselves independently.

    To understand what I'm trying to do, in VB 6.0...
    Add form1 to project
    put a command button (called button1) on form1
    Add Form2 to project
    put a command button (called button1) on form2
    The button1_click event on form1 has one line of code: Form2.show
    The button1_click event on form2 has one line of code: Form1.show

    run the program and you'll see when you click the button on form1...form2 is
    loaded if not already loaded and brought to the top (previously known as
    zorder) When clicking on the button on form2... form1 is loaded if not
    already loaded and brought to the top (previously known as zorder). Closing
    form1 does not close form2 and vice versa.
    ----------------------------------------------------------------------------
    ------------
    Now in .net the only way I am able to come close to duplicating this type of
    behavior is by overloading the New() function for each form to: New(byval
    frmCallingForm as form) ... I store frmCallingForm globally for the form to
    keep it from falling out of scope when the New() is completed...then I
    assign the button1_click event to:
    try
    FrmCallingForm.hide()
    FrmCallingForm.show()
    catch
    FrmCallingForm = new form1(me)
    frmCallingForm.show()
    end try

    -this code has one flaw... open form1, click button1 (which opens form2),
    close form1... both Form1 and form2 close. I would like the forms to be
    independent of one another.

    Some questions:
    1) Anyone notice that forms in .net don't have a Zorder property?
    2) Anyone have a better way of doing this, short of creating a class to
    collect and manage these forms?






  2. #2
    Bill McCarthy Guest

    Re: Form Management in .net vs 6.0

    Hi TMachi,

    have you seen my Q&A column in Visual Studio Magazine. It explains the
    differences between the VB6 and VB.NET forms execution model. I think it
    shoudl have the info you need to get this working, if not post back here and
    we'll see what we can work out.

    You can find my article (and lots more) at www.fawcette.com
    the article and code can be downlaoded for free at present !! from :
    http://www.fawcette.com/Archives/pre...v01/qa0111/qa0
    111.asp




    "TMachi" <tmachi@nam.org> wrote in message news:3c7d50ec$1@10.1.10.29...
    > I've been chasing my tail on this one... any help here would be great.
    >
    > I'm trying to figure out the best way to get two (or more) non-MDI child
    > forms to switch between themselves independently.
    >
    > To understand what I'm trying to do, in VB 6.0...
    > Add form1 to project
    > put a command button (called button1) on form1
    > Add Form2 to project
    > put a command button (called button1) on form2
    > The button1_click event on form1 has one line of code: Form2.show
    > The button1_click event on form2 has one line of code: Form1.show
    >
    > run the program and you'll see when you click the button on form1...form2 is
    > loaded if not already loaded and brought to the top (previously known as
    > zorder) When clicking on the button on form2... form1 is loaded if not
    > already loaded and brought to the top (previously known as zorder). Closing
    > form1 does not close form2 and vice versa.
    > ----------------------------------------------------------------------------
    > ------------
    > Now in .net the only way I am able to come close to duplicating this type of
    > behavior is by overloading the New() function for each form to: New(byval
    > frmCallingForm as form) ... I store frmCallingForm globally for the form to
    > keep it from falling out of scope when the New() is completed...then I
    > assign the button1_click event to:
    > try
    > FrmCallingForm.hide()
    > FrmCallingForm.show()
    > catch
    > FrmCallingForm = new form1(me)
    > frmCallingForm.show()
    > end try
    >
    > -this code has one flaw... open form1, click button1 (which opens form2),
    > close form1... both Form1 and form2 close. I would like the forms to be
    > independent of one another.
    >
    > Some questions:
    > 1) Anyone notice that forms in .net don't have a Zorder property?
    > 2) Anyone have a better way of doing this, short of creating a class to
    > collect and manage these forms?
    >
    >
    >
    >
    >




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