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

  • Home
  • SEARCH
  • 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 8549387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:42:10+00:00 2026-06-11T13:42:10+00:00

private void button2_Click(object sender, EventArgs e) { cl = new ChangeLink(); cl.StartPosition = FormStartPosition.CenterParent;

  • 0
private void button2_Click(object sender, EventArgs e)
        {
            cl = new ChangeLink();
            cl.StartPosition = FormStartPosition.CenterParent;
            DialogResult dr = cl.ShowDialog(this);
            if (dr == DialogResult.Ok)
            {
                if (cl.getText() == "")
                {
                    MessageBox.Show("The TextBox Cannot Be Empty");
                    cl.ShowDialog(this);
                    return;
                }
                else
                {
                    label4.Text = cl.getText();
                    cl.Close();
                }
            }
            else if (dr == DialogResult.Cancel)
            { 
                cl.Close();
            }

cl is a new Form i mgetting the text from.
Now im check that if cl.getText() is empty “” its throwing a message to the user and when the user click ok on the messagebox i want it to return and show the new Form dialog again.
When i click once on the OK button of the new Form and it show the messaeBox message and then show me again the dialogresult box of the new Form but then when i click on OK again and the textBox is still empty it doesnt show the messageBox again just close the new Form and set label4 text to be empty.

I want that each time the user click OK and the textBox is empty it will keep show the new Form textBox dialog untill the user click Cancel or put something in the textBox and then click OK.

  • 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-06-11T13:42:11+00:00Added an answer on June 11, 2026 at 1:42 pm

    It wiil be a lot cleaner if you do the checking in your second Form. You will need to add code to your Form2’s OK Button’s Click Event. Make sure you remove the default DialogResult from the OK Button Property’s.

    private void button2_Click(object sender, EventArgs e)
    {
        if(!string.IsNullOrEmpty(textBox1.Text))
            DialogResult = DialogResult.OK;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

private void button2_Click(object sender, EventArgs e) { ChangeLink cl = new ChangeLink(); // Show
private void button2_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(Data Source=SYS12;Initial Catalog=Teju;Integrated
This is my code: private void button1_Click(object sender, EventArgs e) { DataTable table =
private void frmSearch_Load(object sender, EventArgs e) { // TODO: This line of code loads
I have this code: 001 private void uiButton1_Click(object sender, EventArgs e) 002 { 003
private void button2_Click(object sender, EventArgs e) { //read in file data and calculate record
private void button1_Click(object sender, EventArgs e) { for (int i = 0; i <
When I run the following code: private void button1_Click(object sender, EventArgs e) { Bitmap
I tried to login to gmail with the code: private void button1_Click(object sender, EventArgs
Got this line of code here but its not working. private void Button_Click(object sender,

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.