*Originally posted by Raven_Writer *
**
[Edit: Also, how would you load another form?
EX: In VB6, you do
*form name here*.visible = true
How do you do it in VB .NET? ] **
in .NET, it’s a bit trickier. The catch to remember is that every form in VB.NET is considered an object. Now, I think all the code below is correct, but I don’t have .NET on this machine right now to try it out…
Dim frmShowMe as frmFormToDisplay
frmShowMe = New frmFormToDisplay
frmShowMe.Show
*Originally posted by Nate Smith *
**in .NET, it’s a bit trickier. The catch to remember is that every form in VB.NET is considered an object. Now, I think all the code below is correct, but I don’t have .NET on this machine right now to try it out…
Dim frmShowMe as frmFormToDisplay
frmShowMe = New frmFormToDisplay
frmShowMe.Show
**
Actually, you are almost correct.
It’s
Dim frmholder as new frmtodisplay
frmholder.activate()
frmholder.visible = true
There’s only 1 problem w/ this, if you close out of it, and try to show the frm again, it crashes.
Form setupForm = new frmSetup();
frmSetup.Visible = true;
frmSetup.Activate();
if you want to open it as a modal dialog:
Form setupForm = new frmSetup();
frmSetup.ShowDialog();
The only issue with the first method is that unless you check to see if the form is already open, you’ll have multiple instance of the same form floating around. The difference between the Show() and Activate() methods is that Show() just makes it visible, but Activate() brings it to the front. Activate() only works if the form is visible, so you need to set the Visible property first.
*Originally posted by seanwitte *
**If you want to open a form named frmSetup:
Form setupForm = new frmSetup();
frmSetup.Visible = true;
frmSetup.Activate();
if you want to open it as a modal dialog:
Form setupForm = new frmSetup();
frmSetup.ShowDialog();
The only issue with the first method is that unless you check to see if the form is already open, you’ll have multiple instance of the same form floating around. The difference between the Show() and Activate() methods is that Show() just makes it visible, but Activate() brings it to the front. Activate() only works if the form is visible, so you need to set the Visible property first. **
Welp, that explains the crashing. Thanks seanwitte. Is opening it as a modal dialog better than using the activate() one?
[EDIT: Using the ShowDialog() doesn’t cause a crash in the program (hurray!).]
A modal dialog will keep the focus until you close it. If FormA opens FormB as a dialog, then you can only interact with FormB until you close that form. For most cases its probably fine, normally you’d use it when you need input before doing something else. You are forcing the user to commit or cancel some operation before they can continue.
If you need two forms open at the same time with the user jumping between them then you need to use Activate() or Show(). The Show() method is the equivalent of setting the Visible property to True BTW.
Ok, my program (more specific, a dash-board program) is coming along nice. I have yet another question though. Is it possible to have 2 forms show up, and dock the 2nd one to the first (like what AIM can do with the edge of the screen).
I’ve got this:
switch.dock = dockstyle.right
(switch is already defined). It shows and everything, but I want it to be visible (not behind the main form) when the program starts (for a more clear example, look at roboEmu (http://www.robbayer.com/software.html) program to see what I mean).
*Originally posted by Raven_Writer *
**Ok, my program (more specific, a dash-board program) is coming along nice. I have yet another question though. Is it possible to have 2 forms show up, and dock the 2nd one to the first (like what AIM can do with the edge of the screen).
I’ve got this:
switch.dock = dockstyle.right
(switch is already defined). It shows and everything, but I want it to be visible (not behind the main form) when the program starts (for a more clear example, look at roboEmu (http://www.robbayer.com/software.html) program to see what I mean). **
A few things to start off with:
Traditional docking involves docking one window inside another.
Docking to the edge of the screen (AIM style) and docking one window to another (a-la Winamp) are two very different things.
RoboEmu doesn’t actually use docking. I just tell it to put the Windows in the right place to start. It’s up to the user to keep them that way.
Anyways, I don’t really know much VB, but from what I’ve been able to discern, getting a window to dock to the outside of another one is not an easy task. A quick google search turned up this: http://www.visualbasicforum.com/t54802.html
*Originally posted by rbayer *
**A few things to start off with:
Traditional docking involves docking one window inside another.
Docking to the edge of the screen (AIM style) and docking one window to another (a-la Winamp) are two very different things.
RoboEmu doesn’t actually use docking. I just tell it to put the Windows in the right place to start. It’s up to the user to keep them that way.
Anyways, I don’t really know much VB, but from what I’ve been able to discern, getting a window to dock to the outside of another one is not an easy task. A quick google search turned up this: http://www.visualbasicforum.com/t54802.html **
Thank you rbayer, I didn’t know there was a difference (much) between Winamp-style and AIM-style.
And sorry about he RoboEmu thing…I thought you docked the windows.