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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:03:32+00:00 2026-06-11T12:03:32+00:00

I am new to C#, I am creating a application in which there is

  • 0

I am new to C#, I am creating a application in which there is a need of using two forms
one is Mainform and other is DialogForm.

The DialogForm has two buttons btnYes and btnNo.

whenever the user clicks the close button, FormClosing Event invokes in which I am calling the DialogForm as shown below:

DialogForm ex = new DialogForm();
ex.ShowDialog(this);

Now I want to give e.cancel=false for btnYes and e.cancel=true for btnNo. (this explained by my sir, only basics)

I know how to give functions to a Button which is in same Form but I dont know how to if the Form is different.

I have gone through some links but as I am new to c#, I can’t understand it.
If you atleast provide me some links that would be appreciable.

Thanks in advance.

  • 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-11T12:03:34+00:00Added an answer on June 11, 2026 at 12:03 pm

    Forms have a property DialogResult. You can set it in the button event handlers.

    DialogResult = DialogResult.Yes;
    // or
    DialogResult = DialogResult.No;
    

    Then you can call the form like this

    if (ex.ShowDialog(this) == DialogResult.Yes) {
        // Do something
    } else {
        // Do something else
    }
    

    You can also set the CancelButton property of the form in the properties window. Microsoft says:

    Gets or sets the button control that is clicked when the user presses the ESC key.

    The form has also an AcceptButton property. Microsoft says:

    Gets or sets the button on the form that is clicked when the user presses the ENTER key.

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

Sidebar

Related Questions

i am creating a new android application.i am using the table layout. I have
I'm creating a new web application which will use a bunch of Data Access
I am new to winforms. I am just creating a score card application. There
I am creating a new SDK component (application) based on the sample device located
When creating a new project in netbeans, if i select JAVA Desktop application, it
So within my application is a form for creating a new user, with relevant
I am thinking about creating my new asp.net mvc web application compatible with native
I'm new to PHP and I am currently creating a PHP web application for
I have created a new ActionFilter for an ASP.NET MVC application that I'm creating.
I'm creating new Site Definitions using this method: http://weblogs.asp.net/paulballard/archive/2007/04/09/creating-a-custom-sharepoint-2007-portal-site-definition-using-the-portalprovisioningprovider-class.aspx and when they get created,

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.