Login Form, Application Exit & Leave Event in C#

Post comments in this section to help the beginners...

Page 1 of 1

9 Replies - 22722 Views - Last Post: 03 June 2010 - 10:46 AM Rate Topic: -----

#1 linkpedia   User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 21
  • Joined: 31-July 09

Login Form, Application Exit & Leave Event in C#

Posted 31 July 2009 - 10:29 PM

I want to create a form with two textboxes & one button. How can i code that when the person types the username in firstbox & password in secondbox & then press enter on the keyboard, he/she automatically redirects to the new form. PLEASE HELP ME TO PERFORM THIS THING...

How to use leave event in C#? Whats the purpose of using it?

Finally,
I have develop a hospital management system. Firstpage is of login. When i login to the main page i hide the login page by coding in c#. When i close The application using X button, the application still runs at the back. It does not exit completely...

PLEASE HELP ME OUT GUYZZZ in solving these three problems :rolleyes:

This post has been edited by linkpedia: 31 July 2009 - 11:50 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Login Form, Application Exit & Leave Event in C#

#2 Ändrew   User is offline

  • D.I.C Regular
  • member icon

Reputation: 25
  • View blog
  • Posts: 312
  • Joined: 21-April 08

Re: Login Form, Application Exit & Leave Event in C#

Posted 01 August 2009 - 12:08 AM

For exiting in FormClosing

Application.Exit();



And for pressing enter look at the AcceptButton
In the form propeties.

Ändrew
Was This Post Helpful? 1
  • +
  • -

#3 linkpedia   User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 21
  • Joined: 31-July 09

Re: Login Form, Application Exit & Leave Event in C#

Posted 01 August 2009 - 02:20 AM

View PostÄndrew, on 31 Jul, 2009 - 11:08 PM, said:

For exiting in FormClosing

Application.Exit();



And for pressing enter look at the AcceptButton
In the form propeties.

Ändrew



No you are not understanding what i'm trying to say... Please read my post clearly
Was This Post Helpful? 0
  • +
  • -

#4 przemass   User is offline

  • D.I.C Head

Reputation: 30
  • View blog
  • Posts: 166
  • Joined: 18-July 09

Re: Login Form, Application Exit & Leave Event in C#

Posted 01 August 2009 - 03:58 AM

ad 1.
You must create two forms, one for login and second for... I don't know, you know ;). Every form must be inside own panel. Then by changing visibility of these panels you can first show one panel-form and after correctly login second panel-form. Do you understand?

ad 2.
Read this http://msdn.microsof...trol.leave.aspx
Whats the purpose of using it? It's depends on you. You can for example want automatic validation and when you have input where user must write his email, using leave event on this input you can automaticly validate it and show error when value isn't correctly.

ad 3.
I have no idea, show your code.
Was This Post Helpful? 1
  • +
  • -

#5 Ändrew   User is offline

  • D.I.C Regular
  • member icon

Reputation: 25
  • View blog
  • Posts: 312
  • Joined: 21-April 08

Re: Login Form, Application Exit & Leave Event in C#

Posted 01 August 2009 - 04:53 AM

Quote

No you are not understanding what i'm trying to say... Please read my post clearly


Well I couldnt understand your post...
Was This Post Helpful? 0
  • +
  • -

#6 eclipsed4utoo   User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1536
  • View blog
  • Posts: 5,972
  • Joined: 21-March 08

Re: Login Form, Application Exit & Leave Event in C#

Posted 01 August 2009 - 05:20 AM

View Postlinkpedia, on 1 Aug, 2009 - 05:20 AM, said:

View PostÄndrew, on 31 Jul, 2009 - 11:08 PM, said:

For exiting in FormClosing

Application.Exit();



And for pressing enter look at the AcceptButton
In the form propeties.

Ändrew



No you are not understanding what i'm trying to say... Please read my post clearly


I was going to recommend the same thing. Here is the problem. Most likely, the login form is set as the startup form. Now, if you hide this form, simply closing other forms doesn't close this form. And since this form isn't closed, your application doesn't close completely.

To fix this, you need to do "Application.Exit()" in the form closing event of every form...... Or redesign how your application handles the login form.
Was This Post Helpful? 0
  • +
  • -

#7 linkpedia   User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 21
  • Joined: 31-July 09

Re: Login Form, Application Exit & Leave Event in C#

Posted 02 August 2009 - 10:28 AM

I am totally confused with the post you did. I can't find the Accept Button and apart from this thing I know Application.Exit() but i want to know where and how to code for X icon?
Was This Post Helpful? 0
  • +
  • -

#8 Ändrew   User is offline

  • D.I.C Regular
  • member icon

Reputation: 25
  • View blog
  • Posts: 312
  • Joined: 21-April 08

Re: Login Form, Application Exit & Leave Event in C#

Posted 03 August 2009 - 12:18 AM

Well to code it for the X like i said put it in your FormClosing event you would have to make one. And to find AcceptButton click the form and if in alphabetical order its the 4th one down. And if your using WPF im not sure what the option is called.

Ändrew
Was This Post Helpful? 0
  • +
  • -

#9 Guest_Aspiring_developer*


Reputation:

Re: Login Form, Application Exit & Leave Event in C#

Posted 03 June 2010 - 07:34 AM

The AcceptButton is a property of a button . You can find it by looking up the properties of the button used to login (performs the appropriate function).

Ok with the login form . Code this into your button_click , that will login the user.

if((textbox1.text == "username") && (textbox2.text== "password"))
{
messagebox.show("You have logged in");
form2 f2=new form2();
this.hide();
f2.show();
}
else
{
messagebox.show("Invalid login");
textbox1.focus();
}



Note :-
"username" is the username that you specify and can be any value.
"password" is the password that you specify and can be any value.
f2 is an object created for the 2nd form to call it if the user logs in correctly.
This can be done in many ways varying with the technique. For eg login against validated database, webpage etc..

C# coders have fun ...

This post has been edited by JackOfAllTrades: 03 June 2010 - 07:52 AM
Reason for edit:: Added code tags.

Was This Post Helpful? 1

#10 demausdauth   User is offline

  • D.I.C Addict
  • member icon

Reputation: 190
  • View blog
  • Posts: 693
  • Joined: 03-February 10

Re: Login Form, Application Exit & Leave Event in C#

Posted 03 June 2010 - 10:46 AM

Quote

The AcceptButton is a property of a button . You can find it by looking up the properties of the button used to login (performs the appropriate function).


The AcceptButton is a property of the Form class not the Button class. Not trying to picky... I am pretty sure that was what you meant.

This post has been edited by demausdauth: 03 June 2010 - 10:46 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1