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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:58:57+00:00 2026-05-24T07:58:57+00:00

I have a form Form1 from which I display Form2 as a modal form.

  • 0

I have a form Form1 from which I display Form2 as a modal form. From Form2 I do all sort of editing and deleting of different set of values which should be reflected in Form1 after closing Form2. So what I do is RePopulateControls_in_Form1() after closing Form2. Since RePopulateControls_in_Form1()is a long process, I want to execute that method only if some modification (edit,add, delete) happens in Form2 and not when Form2 is just opened and closed.

So this is what I try to do in Form1:

        Form2 f = new Form2();
        if (f.ShowDialog(this) == DialogResult.Something)
            RePopulateControls_in_Form1()

And then in Form2 I do,

    private void bntEdit()
    {
        //If Edit?
        this.DialogResult = DialogResult.Something;
    }
    private void bntAdd()
    {
        //If Add?
        this.DialogResult = DialogResult.Something;
    }
    private void bntDelete()
    {
        //If Delete?
        this.DialogResult = DialogResult.Something;
    }

But my problem is .Something. If it is anything other than .None, Form2 simply gets closed. I do not want Form2 to get simply closed by its own unless the user closes it.

If I do this:

    //in Form1
    private void Form1_Click()
    {
        Form2 f = new Form2();
        if (f.ShowDialog(this) == DialogResult.None)
            RePopulateControls_in_Form1()
    }

    //in Form2
    private void Form2_SomeModification()
    {
        //If Modified?
        this.DialogResult = DialogResult.None;
    }

RePopulateControls_in_Form1() is not hit!

In short, in my program how can I tell the compiler to call RePopulateControls_in_Form1() only if values are modified in Form2?

Note: Repopulating is certainly required since the controls are dynamically created and a bit complex (actually what is created in Form2 is GUI controls and its labels etc).

  • 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-24T07:58:57+00:00Added an answer on May 24, 2026 at 7:58 am

    Setting DialogResult on Form hides the form and returns from ShowDialog. If you want to delay that until the user performs some other action (such as closing the form) you should store that state as a member field and set DialogResult in a handler for Form.Closing.

    Also, if you do want to dismiss the modal form on a button press, you can use the Button.DialogResult property instead of making a Button.Click handler.

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

Sidebar

Related Questions

I have CustomForm inherited from Form which implements a boolean property named Prop .
I have a form and from this I call dialogPrintDiet.ShowDialog() which launchs my dialog.
I have a html form which have a select list box from which you
I have a form in which the user can choose a component type from
I have a winforms form which is inherited from another form. e.g. class StartForm
I have made a class which a form can inherit from and it handles
I have a Ruby DateTime which gets filled from a form. Additionally I have
I have an embedded iframe form which takes a file from a type=file form
I have an application which takes a string value of the form %programfiles%\directory\tool.exe from
I have a form like: #forms.py from django import forms class MyForm(forms.Form): title =

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.