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 9069281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:23:18+00:00 2026-06-16T17:23:18+00:00

I have two Forms in my application. They way I call Form 2 is

  • 0

I have two Forms in my application. They way I call Form 2 is like this:

Form 1:

private void btnTest_Click(object sender, EventArgs e)
{
    DialogResult result = new System.Windows.Forms.DialogResult();
    Add_Link addLink = new Add_Link();
    result=addLink.ShowDialog();

    if (result == System.Windows.Forms.DialogResult.OK)
    {
        //
    }
}

Form 2:

private void btnAdd_Click(object sender, EventArgs e)
{            
    if(validURL(txtSubLink.Text))
    {
        HyperLink add = new HyperLink(txtSubLink.Text,txtSubText.Text,"URL");
        this.build = add;                 
    }
    else
    {
        MessageBox.Show("Valid URL Needed! " + txtSubLink.Text, "ERROR");
    }             
}

My problem is if the user clicks the Add button, the error message shows(because the data is invalid or the textboxes are empty) BUT it closes the form. I only want the user to close the form and pass the data back if the two textboxes contain the proper data. If the two textboxes don’t contain the proper data OR is empty, when the user clicks Add, the error message should show, and the Form 2 should remain open, How do I get that to happen…?

  • 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-16T17:23:19+00:00Added an answer on June 16, 2026 at 5:23 pm

    I suspect your btnAdd has its DialogResult property set to OK. Unset that, and then add this.DialogResult = DialogResult.OK in your event handler when you’re satisfied with the input.

    private void btnAdd_Click(object sender, EventArgs e)
    {
    
        if(validURL(txtSubLink.Text))
        {
             HyperLink add = new HyperLink(txtSubLink.Text,txtSubText.Text,"URL");
             this.build = add;
             this.DialogResult = DialogResult.OK;
    
        }
        else
        {
            MessageBox.Show("Valid URL Needed! " + txtSubLink.Text, "ERROR");
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created two forms in my Windows Application. One Form acts as a
I have an application that consists of two forms. One form displays data returned
If I have two DataGridView items in a C# Win Forms application, and they
I have two versions of a Windows Forms Application and can't figure for the
I have encountered a problem in my application. I have two forms, one that
Scenario I have a windows forms application. I want to use two different WCF
I have application in VB.net that have two different form (Form1 and Form2). Now
Imagine that I have a form in a flash application with two fields, input1
In my rails application I have two models called Kases and Notes. They work
I have been experimenting with sending messages from two .NET Windows Forms applications using

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.