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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:23:01+00:00 2026-06-19T00:23:01+00:00

In the closing event i have this: private void Form1_FormClosing(object sender, FormClosingEventArgs e) {

  • 0

In the closing event i have this:

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            FormIsClosing = true;
            KeysValuesUpdate();
        }

FormIsClosing is a flag.

Then this is the KeysValuesUpdate function:

public void KeysValuesUpdate()
        {
            using (var w = new StreamWriter(keywords_path_file))
            {
                if (FormIsClosing == true)
                crawlLocaly1 = new CrawlLocaly(this);
                crawlLocaly1.StartPosition = FormStartPosition.CenterParent;
                if (FormIsClosing == true)
                DialogResult dr = crawlLocaly1.ShowDialog(this);
                if (dr == DialogResult.OK)
                {
                    if (LocalyKeyWords.ContainsKey(mainUrl))
                    {
                        LocalyKeyWords[mainUrl].Clear();
                        LocalyKeyWords[mainUrl].Add(crawlLocaly1.getText());
                    }
                    else
                    {
                        LocalyKeyWords[mainUrl] = new List<string>();
                        LocalyKeyWords[mainUrl].Add(crawlLocaly1.getText());
                    }
                    Write(w);
                    ClearListBox();
                }
                if (dr == DialogResult.Cancel)
                {
                    Write(w);
                }
            }
        }

The problem is if im doing just if (FormIsClosing == true) the the next line i want not to take effect im getting error on it:

Error 1 Embedded statement cannot be a declaration or labeled statement
And the line after it : dr is unsigned.

If im doing:

if (FormIsClosing == true)
{
                    DialogResult dr = crawlLocaly1.ShowDialog(this);
}

Then dr is unsign on this line: if (dr == DialogResult.OK)

What i want to archive is that if i close my application just dont show this dialog first.
And the line that show the dialog is: DialogResult dr = crawlLocaly1.ShowDialog(this);

  • 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-19T00:23:02+00:00Added an answer on June 19, 2026 at 12:23 am

    Update from OP’s comment

    Here’s how you can display the form when the program is not closing:

                DialogResult dr = DialogResult.None;//Increase accessibility domain, setup a good default value
                if (FormIsClosing != true)
                {
                  dr = crawlLocaly1.ShowDialog(this);
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this event in a new Form: private void CrawlLocaly_FormClosed(object sender, FormClosedEventArgs e)
I have the following code: private void form1_closing(object sender, FormClosingEventArgs e) { e.Cancel =
I have a button click event handler with the following pseudo code: private void
private void buttonAddJobActionPerformed(java.awt.event.ActionEvent evt) { try { retrieveID(); String sqlStm = INSERT INTO Job
Ok, so I have seen this solution to closing a fancybox via a button
I have VS 2010 and want to cancel the form closing event via a
'This is the event that is fired as the application is closing, whether it
I have a simple Form-Based .NET application. In this I capture the FormClosing Event
Ok, i have a closing event on my form. The code inside it fades
(WindowClosing) when i am using window event for closing current frame, in that it

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.