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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:13:46+00:00 2026-06-12T19:13:46+00:00

guys! I’ve got 2 forms in application – working form (frmMain) and form of

  • 0

guys!
I’ve got 2 forms in application – working form (frmMain) and form of settings (frmSettings).
There are two buttons on frmSettings – Save and Cancel. In frmMain I use the following approach to show the frmSettings:

 private void btnSettings_Click(object sender, EventArgs e)
        {
            frmSettings = new SettingsForm();
            frmSettings.ShowDialog();
            // ...
        }

The problem is I don’t know, how to detect, which button was pressed on the frmMain – Save or Cancel. The further logic of the program depends on this fact. I need something like this:

private void btnSettings_Click(object sender, EventArgs e)
        {
            frmSettings = new SettingsForm();
            frmSettings.ShowDialog();

            if(/* frmSettings.SaveButton.WasClicked == true */)
            {
                InitializeServices();
            }
            // ...
        }

Please, give me an advice, how to implement such kind of interaction between forms. Better without using global variables for saving buttons state.
Thanks beforehand.

  • 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-12T19:13:48+00:00Added an answer on June 12, 2026 at 7:13 pm

    ShowDialog returns a DialogResult object that allow you to know that. You have to:

    On Save Button’s click event, set this.DialogResult to DialogResult.OK

    On Cancel Button’s click event, set this.DialogResult to DialogResult.Cancel

    private void btnSettings_Click(object sender, EventArgs e)
    {
       frmSettings = new SettingsForm();
       if(frmSettings.ShowDialog() == DialogResult.OK)
       {
           InitializeServices();
       }
       //.......    
    }
    

    Edited to manage the DialogResult as @tsiorn’s answer: setting form’s DialgoResult insted of setting that property on each button.

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

Sidebar

Related Questions

guys. I have two view controllers with two uiwebviews. Here is my code: First
guys i got a php file that use it as xml for a flash
Guys, Is there an easy way to return different fields names from different models
Guys i am making c# windows application and i want to open any explorer
guys. I'm working on some audio services on iOS. I trying to search any
Guys I've a situation here, I've a HTTP handler ( InsertMap.ashx ) to save
Guys i have to do a insert in to a table when there is
guys :) I'm using local notification in my application and I provide action for
guys just wondering if there is a better style of coding to get the
Guys here is my html form code. What I want is when I click

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.