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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:55:18+00:00 2026-05-26T18:55:18+00:00

I’m having a bit weird problem with WinForm which seems to refuse to close

  • 0

I’m having a bit weird problem with WinForm which seems to refuse to close for some weird reason. I’ve got very simple gui which sometimes doesn’t react for me pressing X or when i use events on buttons it even reaches Close() and does nothing..

    private void buttonZapisz_Click(object sender, EventArgs e) {
        string plik = textBoxDokumentDoZaladowania.Text;
        if (File.Exists(plik)) {
            string extension = Path.GetExtension(plik);
            string nazwaPliku = Path.GetFileName(plik);

            SqlMethods.databaseFilePut(plik, comboBoxTypDokumentu.Text, textBoxKomentarz.Text, sKlienciID, sPortfelID, extension, nazwaPliku);
            Close();
        }
    }

There are no events assigned to FormClosed or FormClosing. So how can I find out what’s wrong. Sometimes X will work after the GUI is loaded but after i press Button to save some stuff to database it reaches Close() in that button event and it still is visible and does nothing. Can’t use X, nor ALT+F4. I can go around GUI and choose other values for ComboBox without problem.

I call GUI like this:

    private void contextMenuDokumentyDodaj_Click(object sender, EventArgs e) {
        var lv = (ListView) contextMenuDokumenty.SourceControl;
        string varPortfelID = Locale.ustalDaneListViewKolumny(listViewNumeryUmow, 0);
        string varKlienciID = Locale.ustalDaneListViewKolumny(listViewKlienci, 0);

        if (lv == listViewDokumentyPerKlient) {
            if (varKlienciID != "") {
                var dokumenty = new DocumentsGui(varKlienciID);
                dokumenty.Show();
                dokumenty.FormClosed += varDocumentsGuiKlienci_FormClosed;
            }
        } else if (lv == listViewDokumentyPerPortfel) {
            if (varPortfelID != "" && varKlienciID != "") {
                var dokumenty = new DocumentsGui(varKlienciID, varPortfelID);
                dokumenty.Show();
                dokumenty.FormClosed += varDocumentsGuiPortfele_FormClosed;
            }
        } 
    }

While I can’t close GUI i can work on the main gui without problem too. I can open up same GUI and after opening new GUI i can quickly close it. GUI is very simple with few ComboBoxes,TextBoxes and one EditButton from Devexpress.

Edit: varDocumentsGuiPortfele_FormClosed code allows me to refresh GUI (reload ListView’s depending on where the user is on now).

    private void varDocumentsGuiPortfele_FormClosed(object sender, FormClosedEventArgs e) {
        TabControl varTabControl = tabControlKlientPortfele;

      if (varTabControl.TabPages.IndexOf(tabPageDokumentyPerKlient) == varTabControl.SelectedIndex) {
          loadTabControlKlientPortfeleBezZmianyUmowy();

      }
    }
  • 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-26T18:55:18+00:00Added an answer on May 26, 2026 at 6:55 pm

    Paste this code into your form classes:

        protected override void OnFormClosing(FormClosingEventArgs e) {
            e.Cancel = false;
            base.OnFormClosing(e);
        }
    

    When that works, you want to find out why you have Validating event handlers that don’t want the form to be closed.

    Next thing you want to verify is Debug + Exceptions, tick the Thrown box for CLR Exceptions. This makes sure you don’t swallow an exception that prevents a form from closing. Or worse, the operating system swallowing the exception, a nasty Windows 7 problem.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.