|
-
Dec 15th, 2006, 03:21 PM
#12
Hyperactive Member
Re: how to close form1 when i open form2?
 Originally Posted by tr333
read this: http://vbforums.com/showthread.php?t=313050
its written for vb.net, but the ideas are the same...
basically you want to declare the reference to the new form as a public variable, something which cannot be done inside a method.
Code:
public Form newform = null;
public static void Main() {
...
then you can use the code that was first posted (slightly modified):
Code:
// newform has already been declared as a public variable
newform = new Form2();
newform.Show();
this.Close();
since the new form is no longer a child of the loginform, it won't disappear when the loginform is closed.

I've tried placing a public declaration of a form EVERYWHERE, and it just doesn't work.
I've put it in a class, before a class, before main, and got a million errors.
It works when I put it in a class, however because I have to recreate the class in the form, it closes that form and the current form also:
VB Code:
class variables
{
public string windowsuser;
public mainos osform = new mainos();
}
In form1:
VB Code:
timer4.Enabled = false;
vars.osform = new mainos();
vars.osform.Show();
this.Close();
» Twitter: @rudi_visser : Website: www.rudiv.se «
If Apple fixes security flaws, they are heralded as proactive. If Microsoft fixes a security flaw, they finally got around to fixing their buggy OS.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|