473,508 Members | 2,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Close form...

Hi.

Imagine a scene where the user input the username and password in a "Login"
form and when press the confirm button, another window is opened with the
"Main" form. After that, the "Login" form is "closed" automatically.

How can I do to close the "Login" form? If I use Login.Close() on the
button_click event, both forms are closed.
Thanks a lot.

Fabio Negri Cicotti
Nov 16 '05 #1
4 1921
Fabio,

I would just run two message loops. The code that VS.NET produces for
you looks like this:

// Run the message loop with a form.
Application.Run(new Form1());

There is nothing that stops you from doing this:

// The login form.
LoginForm pobjLoginForm = new LoginForm();

// Show the login form.
Application.Run(pobjLoginForm);

// Apply some logic here, based on the properties of the form, like if the
user succeeded in logging in or not.

// Run the main form here.
Application.Run(new MainForm());

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Fabio Negri Cicotti" <ci*****@hotmail.com> wrote in message
news:uF**************@TK2MSFTNGP12.phx.gbl...
Hi.

Imagine a scene where the user input the username and password in a "Login" form and when press the confirm button, another window is opened with the
"Main" form. After that, the "Login" form is "closed" automatically.

How can I do to close the "Login" form? If I use Login.Close() on the
button_click event, both forms are closed.
Thanks a lot.

Fabio Negri Cicotti

Nov 16 '05 #2
Thanks for your reply Nicholas.

I have tried to do what you said, but I didn't get successful. I'm taking
the follow error message:

"Additional information: It is invalid to start a second message loop on a
single thread. Use Application.RunDialog or Form.ShowDialog instead."
Any help is appreciated,

Fabio Negri Cicotti

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Or*************@TK2MSFTNGP10.phx.gbl...
Fabio,

I would just run two message loops. The code that VS.NET produces for
you looks like this:

// Run the message loop with a form.
Application.Run(new Form1());

There is nothing that stops you from doing this:

// The login form.
LoginForm pobjLoginForm = new LoginForm();

// Show the login form.
Application.Run(pobjLoginForm);

// Apply some logic here, based on the properties of the form, like if the
user succeeded in logging in or not.

// Run the main form here.
Application.Run(new MainForm());

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Fabio Negri Cicotti" <ci*****@hotmail.com> wrote in message
news:uF**************@TK2MSFTNGP12.phx.gbl...
Hi.

Imagine a scene where the user input the username and password in a

"Login"
form and when press the confirm button, another window is opened with the "Main" form. After that, the "Login" form is "closed" automatically.

How can I do to close the "Login" form? If I use Login.Close() on the
button_click event, both forms are closed.
Thanks a lot.

Fabio Negri Cicotti


Nov 16 '05 #3
Hi, Fabio

that's exactly what you need - ShowDialog for login form.
What stops you to use it before doing Application.Run for main form?

HTH
Alex

"Fabio Negri Cicotti" <ci*****@hotmail.com> wrote in message
news:OU**************@TK2MSFTNGP10.phx.gbl...
Thanks for your reply Nicholas.

I have tried to do what you said, but I didn't get successful. I'm taking
the follow error message:

"Additional information: It is invalid to start a second message loop on a
single thread. Use Application.RunDialog or Form.ShowDialog instead."
Any help is appreciated,

Fabio Negri Cicotti

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:Or*************@TK2MSFTNGP10.phx.gbl...
Fabio,

I would just run two message loops. The code that VS.NET produces for
you looks like this:

// Run the message loop with a form.
Application.Run(new Form1());

There is nothing that stops you from doing this:

// The login form.
LoginForm pobjLoginForm = new LoginForm();

// Show the login form.
Application.Run(pobjLoginForm);

// Apply some logic here, based on the properties of the form, like if the user succeeded in logging in or not.

// Run the main form here.
Application.Run(new MainForm());

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Fabio Negri Cicotti" <ci*****@hotmail.com> wrote in message
news:uF**************@TK2MSFTNGP12.phx.gbl...
Hi.

Imagine a scene where the user input the username and password in a

"Login"
form and when press the confirm button, another window is opened with

the "Main" form. After that, the "Login" form is "closed" automatically.

How can I do to close the "Login" form? If I use Login.Close() on the
button_click event, both forms are closed.
Thanks a lot.

Fabio Negri Cicotti



Nov 16 '05 #4
Fabio,

Interesting, what version of the framework are you running on? I am on
1.1, and it doesn't prevent me from doing this.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Fabio Negri Cicotti" <ci*****@hotmail.com> wrote in message
news:OU**************@TK2MSFTNGP10.phx.gbl...
Thanks for your reply Nicholas.

I have tried to do what you said, but I didn't get successful. I'm taking
the follow error message:

"Additional information: It is invalid to start a second message loop on a
single thread. Use Application.RunDialog or Form.ShowDialog instead."
Any help is appreciated,

Fabio Negri Cicotti

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:Or*************@TK2MSFTNGP10.phx.gbl...
Fabio,

I would just run two message loops. The code that VS.NET produces for
you looks like this:

// Run the message loop with a form.
Application.Run(new Form1());

There is nothing that stops you from doing this:

// The login form.
LoginForm pobjLoginForm = new LoginForm();

// Show the login form.
Application.Run(pobjLoginForm);

// Apply some logic here, based on the properties of the form, like if the user succeeded in logging in or not.

// Run the main form here.
Application.Run(new MainForm());

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Fabio Negri Cicotti" <ci*****@hotmail.com> wrote in message
news:uF**************@TK2MSFTNGP12.phx.gbl...
Hi.

Imagine a scene where the user input the username and password in a

"Login"
form and when press the confirm button, another window is opened with

the "Main" form. After that, the "Login" form is "closed" automatically.

How can I do to close the "Login" form? If I use Login.Close() on the
button_click event, both forms are closed.
Thanks a lot.

Fabio Negri Cicotti



Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2727
by: marcelf3 | last post by:
Hello.. This page opens a window with some information, but everytime the user changes a field in the parent window, the child window needs to be closed. These 2 functions were supposed to do the...
1
2085
by: Jules Winfield | last post by:
My WinForms application can have any number of top level forms open at a given time. If the user selects File|Exit, all of the forms are closed. The loop to close the forms looks something like this:...
2
4982
by: Chien Lau | last post by:
Hi, At a certain point in my application, I have access to a Form object. I want to close that form: form.Close(); There are any number of reasons why this form might not close. A common...
7
2506
by: Alice | last post by:
Hi, In my program, the user can navigate to many different forms. When they go to the next form, I want the form they have left to close. However, the forms aren't closing. Can anyone tell me...
5
11054
by: Stan Sainte-Rose | last post by:
Hi, Which event is called when the user click on the close window icon (X) ? I want, when he clicks on this icon, to display a message before closing the form. If he replys by No, I don't want to...
6
6640
by: Tom | last post by:
Is there ANY easy way to close a MDI Child form in the middle of it's load? For instance, during the Load event I find a need to close the form (for whatever reason - maybe the user isn't ready for...
5
7426
by: AP | last post by:
IS there a way to run a procedure if the users close access directly rather than closing a menu screen that I have built? There is an event that works on close for this form, but it doesnt seem to...
6
6982
by: scott | last post by:
I guess this is a simple one but I can't seem to get it to work. I want to refresh an open form "onClose" of another. I have a Close button on a form which has User Details on it. If I update...
3
4381
by: rdemyan via AccessMonster.com | last post by:
I need help with code to close two forms at the same time, FormA and FormB. I need code that can be used from either form and needs to work with both a 'Close' button on each form as well as if the...
1
3850
by: dan.c.roth | last post by:
oForm.Close() vs this.Close() in a modal dialog. oFrom.Close() calls Form.Dispose() but this.Close() ,say in the click event of the Form, does not. I can think of the reason for this but is...
0
7228
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7128
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7332
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3191
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1565
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.