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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:00:25+00:00 2026-06-09T05:00:25+00:00

myDialog d = new myDialog(); d.ShowDialog(); Once my dialog processes some input, I do

  • 0
myDialog d = new myDialog(); 
d.ShowDialog();

Once my dialog processes some input, I do a

this.Close();

from within the dialog class.

then back in my main window, I check a variable i.e.

if (d.OK = true)
{
//do stuff
}

Is this ok if several of these dialogs will be created as the program is used? Or should I use a static variable on my main form that references the same dialog? Does it make a difference?

  • 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-09T05:00:26+00:00Added an answer on June 9, 2026 at 5:00 am

    Use this pattern and your dialog will always be correctly disposed

    using(myDialog d = new myDialog())
    {
         if(DialogResult.OK == d.ShowDialog())
         { 
             //do stuff (for example, read some property values on the dialog)
             if(d.ExecuteSomeAction == true)
                  // Do some action -> call a database query or something.....
         } 
    }
    

    Using a static variable to maintain the dialog from disposing (and in that case you should call this.Hide() not this.Close() is, in my opinion, a bad practice, unless you need to keep track of a ‘state condition’ or propose to your users their last inputs. You should also be very carefull in closing the static variable when you app close.

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

Sidebar

Related Questions

I have a form and from this I call dialogPrintDiet.ShowDialog() which launchs my dialog.
I am creating a custom dialog as: Dialog myDialog = new Dialog(context, R.style.Theme_Levels); myDialog.setContentView(R.layout.levelselector);
In my QMainWindow class, i have another class named MyDialog that inherits from qdialog.
If I create a class derived from System.Windows.Window and show it with ShowDialog it
This is how my dialog is generated: $(function () { $(.btnDialog).click(function() { //e.preventDefault(); var
I'm new to Android development, I needed to implement custom dialog plugin similar to
Can I inflate PreferenceScreen inside an alert dialog? This is what I've tried: final
I'm new to WPF so this is probably a pretty easy problem. I open
I have some code here (my activity class and some class, that extends WebViewClient)
I am using NetBeans' GUI Designer to create some JDialog s, which I then

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.