Results 1 to 10 of 10

Thread: WinForms Login

Threaded View

  1. #1

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    WinForms Login

    C# version here.

    Here are some simple steps to create login functionality in your WinForms app.

    1. Create a new WinForms project.
    2. Add a new form to act as the Login dialogue. You can use the item template supplied with VS or create your own.
    3. Open the ApplicationEvents code file from the button on the Application tab of the project properties.
    4. Create a Startup event handler using the drop-down lists at the top of the code file and add the following code:
    vb.net Code:
    1. Using loginDialogue As New LoginForm1
    2.     e.Cancel = (loginDialogue.ShowDialog() <> DialogResult.OK)
    3. End Using
    5. Add the logic to your Login form to validate the credentials supplied by the user. You may like to use this as a basis.
    6. If the login succeeds set your Login dialogue's DialogResult property to OK. If the user presses the Cancel button or fails to login within a prescribed maximum number of attempts then set the DialogResult to something else.

    If the user logs in successfully the app will start normally, otherwise it will exit without ever creating a main form.
    Last edited by jmcilhinney; Dec 14th, 2008 at 10:35 PM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width