473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Login form disgard

I have a login form, that if successfully answered, launches another
form. The problem is that the login form remains even after I show the
main form. How do I get rid of the login form?

Nov 17 '05 #1
5 1803
JPSutor,

You could just set the visibility of the form to false, but I don't
think that is a good idea. Rather, you should do the following:

// Declare any variables you need to pass to your main form here.

// Create your form here.
using (LoginForm loginForm = new LoginForm())
{
// Run the login form.
Application.Run(loginForm);

// Set the variables which you will pass to your main form here.
// You need to do this because your form will be disposed after the
// using statement block is exited.
}

// Call your main form now.
// Pass in any parameters you might need to the constructor.
// A using block is not needed here because it is assumed
// that your program is exiting after this line (or
// shortly after that).
Application.Run(new MainForm());

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"JPSutor" <jp*****@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I have a login form, that if successfully answered, launches another
form. The problem is that the login form remains even after I show the
main form. How do I get rid of the login form?

Nov 17 '05 #2
Hi,

Just Hide() it, you cannot close it, as this is probably your main form (
the one you call from Application.Run )
Just hide it and use ShowDialog, after that just close the login form,
A piece of code will help:

void Login_Click( object sender, EventArgs e)
{
if ( CheckLogin() )
{
this.Hide();
Form newForm = MyNewForm();
newForm.ShowDialog();
this.Close()
}
else
{
MessageBox.Show("Incorrect login");
}
}
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"JPSutor" <jp*****@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I have a login form, that if successfully answered, launches another
form. The problem is that the login form remains even after I show the
main form. How do I get rid of the login form?

Nov 17 '05 #3
I don't know if I like that. That's keeping around a window and all of
its associated controls for a pretty long period of time that you really
don't need to.

I'd rather show it, dispose of it, then show the main form. It leads to
better program design as well.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:eF**************@TK2MSFTNGP10.phx.gbl...
Hi,

Just Hide() it, you cannot close it, as this is probably your main form
( the one you call from Application.Run )
Just hide it and use ShowDialog, after that just close the login form,
A piece of code will help:

void Login_Click( object sender, EventArgs e)
{
if ( CheckLogin() )
{
this.Hide();
Form newForm = MyNewForm();
newForm.ShowDialog();
this.Close()
}
else
{
MessageBox.Show("Incorrect login");
}
}
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"JPSutor" <jp*****@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I have a login form, that if successfully answered, launches another
form. The problem is that the login form remains even after I show the
main form. How do I get rid of the login form?


Nov 17 '05 #4
Hi,

You are right, but most probably the form will consist of two pairs of
textbox/label and two buttons, it would have almost no impact in the system.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:u4**************@TK2MSFTNGP10.phx.gbl...
I don't know if I like that. That's keeping around a window and all of
its associated controls for a pretty long period of time that you really
don't need to.

I'd rather show it, dispose of it, then show the main form. It leads
to better program design as well.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:eF**************@TK2MSFTNGP10.phx.gbl...
Hi,

Just Hide() it, you cannot close it, as this is probably your main form
( the one you call from Application.Run )
Just hide it and use ShowDialog, after that just close the login form,
A piece of code will help:

void Login_Click( object sender, EventArgs e)
{
if ( CheckLogin() )
{
this.Hide();
Form newForm = MyNewForm();
newForm.ShowDialog();
this.Close()
}
else
{
MessageBox.Show("Incorrect login");
}
}
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"JPSutor" <jp*****@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I have a login form, that if successfully answered, launches another
form. The problem is that the login form remains even after I show the
main form. How do I get rid of the login form?



Nov 17 '05 #5
I indirectly create a login form via "onload" of main, gather required info
then dispose of the form.
public bool getProfile(Form myForm) // Method of Class Instanciated by
Main_Onload

{
frmLogin myLogin = new frmLogin();

if(myLogin.ShowDialog() == DialogResult.OK){

ArrayList pal = new ArrayList(myLogin.sParameters);

if(pal.Count !=RequiredNumber)return false;

param1 = (string)pal[0];

param2 = (string)pal[1];

etc....

myLogin.Dispose();

return true;}

}

Hope this helps,

Dave
"JPSutor" <jp*****@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I have a login form, that if successfully answered, launches another
form. The problem is that the login form remains even after I show the
main form. How do I get rid of the login form?



Nov 17 '05 #6

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

Similar topics

5
by: Simon | last post by:
Hi, I have a Login.php page that logs the user in and out. I has two forms within the page, (depending on what we are trying to do), either one to log in or out. The form calls itself using a...
1
by: John Davis | last post by:
I put a little login (username and password textfields) in a web page, and once the user able to login, I want the username and password textfields will disappear, and replace with text " has...
1
by: Wayne Smith | last post by:
Applies to: Microsoft FrontPage 2000, Microsoft Access 2000, IIS 5.0 Operating System: Microsoft Windows 2000 Professional I am trying to protect a portion of a web site by allowing users to...
3
by: Dam6 | last post by:
Okay... Using vb .net within DW MX2004, connecting to an access database: Background: I have created a simple login.aspx page that is supposed to re-direct to default.aspx using...
3
by: Bob | last post by:
I haver a user login form (winforms app using vs2005 in VB.NET). After succesfull validayion of user I want to open a first form and close the loging form that was used, If I write If...
13
by: knot2afrayed | last post by:
I am trying to fix error- object does not exist- I want it possible to allow object not to exist. I am writing a script on a page that may or may not include a login form. For example-after a...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
1
by: Kandiman | last post by:
Hiya, i made a asp page, and one of my divs (as a include) is as below. the problem is if the main page is resubmitted, i get logged out again?... heres the code.. i think its on the value=true...
21
by: tvnaidu | last post by:
This is the Java script I am using fo rlogin page, but cursor not pointing to login box, any idea how can I point cursor to login box when this page loaded?. here admin login take to control page and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...

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.