|
||
|
|
#1 (permalink) | |
|
Forum Expert
|
Ok, I am using Visual Studio 2k5 Express Edition...
Now, if you've ever used it, you'll know it generates Form code VERY cleanly. This aside, I have the 'Start' Form that starts up from Main. Then I have a button that leads to Form2. This button is supposed to: -Close(not hide) the Start Form. -Create a new instance of Form2. Code? I tried[in start as the button is in that form]: Code:
Form2 ff = new Form2(); ff.Show(); this.Close(); -Storm
__________________
Quote:
|
|
|
|
|
|
|
#2 (permalink) |
|
Join Date: Feb 2003
Posts: 33
|
Well since Form1 is your mainform you cannot close it without closing the application. Thats the reason why both forms are closed. Even if you do not define Form1 as the parent form for Form2.
So you only can hide Form1. The reason can be found in the hidden part of the partitial class of Form1. Ther should be some line like. void main() { Application.Run(new Form1()); } |
|
|
|
|
|
#3 (permalink) |
|
ConnectUO Creator
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,762
|
Form2 ff = new Form2();
ff.Show(); this.Hidden = true; try that
__________________
Jeff Boulanger ConnectUO - Core Developer Want to help make ConnectUO better? Click here to submit your ideas/requests Use your talent to compete against other community members in RunUO hosted coding competitions If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team. Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO |
|
|
|
|
|
#4 (permalink) | ||
|
Forum Expert
|
Quote:
Quote:
Of course, some trickery would need to be involved if you wanted this to happen only when the Button is used and not when the form is closed in some other way, but this is a (hackish) way to do this. |
||
|
|
|
|
|
#7 (permalink) | |
|
Join Date: Feb 2003
Posts: 33
|
Quote:
Well since you only do not want to not make a new instance why not call Form2 as a modal dialog with that code (pseudocode) Code:
funktion showmeForm2()
{
HideForm1();
ShowModalDialog(Form2);
UnhideForm1();
}
Since If you want to hide/clode Form1 I see no need to use an unmodal dialog. Last edited by swtrse; 06-22-2006 at 06:35 AM. |
|
|
|
|
|
|
#8 (permalink) | |
|
Forum Expert
|
Quote:
Its parts that are not marked as being designer generated code most likely have about as much chance of being arbitrarily changed by the designer as the Main method does (note that I'm talking about logic, not about the identifiers). The only parts that one would really have to worry about being changed would be the code in the (FileName).Designer.cs part that (FileName).cs is split into, and even in that the code that is routinely changed is marked off by a region (except for the field declarations). Anyways, I never once said I would recommend doing it that way, only that it was a way that could accomplish what he wanted in some fashion, I even acknowledged that it was a hackish way to do it, I was just presented some form of a solution that met his restrictions in his first post. Last edited by Sep102; 06-22-2006 at 07:43 PM. |
|
|
|
|
|
|
#9 (permalink) |
|
Join Date: Feb 2003
Posts: 33
|
Wellwtih designer generated code I was refering to
.NET 1.0+1.1: the region within the generated class telling you that this is gernerated code and should not be changed. .NET 2.0: parts of partitial classes or clases marked with the GeneratedCodeAttribute. Hope that makes it clear. |
|
|
|
|
|
#10 (permalink) | |
|
Forum Expert
|
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|