Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6809305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:04:13+00:00 2026-05-26T20:04:13+00:00

I am using windows forms application using C#. I have created a dialog box

  • 0

I am using windows forms application using C#. I have created a dialog box that requests the user for login details such as a username and password. using If-else statement, If login details match, a message box stating “success” appears and the dialog box closes automatically. this is fine. but, if I enter wrong login details, I make a message box appear in the else statement, stating that “wrong details entered”. But, then when I close that message box, the dialog box disappears. I do not want this to happen. I want the dialog box to remain in view for the user to enter correct details again. is there some lines of code that I should enter to avoid closing of the dialog box?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:04:14+00:00Added an answer on May 26, 2026 at 8:04 pm

    I would suggest you to create a new form and then show it as dialog:

    1) Create new form
    2) Set MinimizeButton of Form to false
    3) Set MaximizeButton of Form to false
    4) Add components: 1x textfield, 2x button (ok button and cancel button)
    5) Set DialogResult of Ok Button to: OK
    6) Set DialogResult of Cancel Button to: Cancel
    7) Add a public method: public string GetText() { return textbox.text };
    8) Set password char for textbox

    In your main form:

    var dialogForm = new MyNewForm();
    if (dialogForm.ShowDialog() != DialogResult.OK)
    {
       Application.Exit()
    }
    else 
    {
       var pw = dialogForm.GetText(); // string var pw stores the enterd pw now
       // validate your password here
    
       if (PasswordIsCorrect())
       {
          // some logic here
       } 
    }
    

    If you want to display the Dialog in a loop, replace “if (dialogForm.ShowDialog() … ” with “while …”

    Attention: Code untestet
    Attention 2: Please make sure that your validation logic is safe. Experienced users can decompile your application to get the validation logic

    Hope that helps? Kind regards

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a Windows Forms application in .NET 2 using C# that runs
I have created a textbox in a Windows Forms application that starts out at
I have created one Windows Forms application with C# and MySQL (using MySQL Connector
I'm creating a multilingual application using Windows Forms. I have created my multilingual content
I have a Windows Forms application that was created in Visual Studio 2008 and
Im using c# .net windows form application. I have many databases created using sql
Im using c# .net windows application form. I have created many databases with many
I am considering using ClickOnce for a legacy Windows Forms application. I have several
I have a three-tier Windows Forms DB application in VB.NET. I'm using VS 2005.
Using Visual Studio 2008, c#, .net 2.0. I have a Windows Forms client application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.