I have a slightly strange problem with WinForm that seems to refuse to close for some strange reason. I have a very simple gui that sometimes doesnβt respond when I press 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 by FormClosed or FormClosing . So how can I find out what happened. Sometimes X will work after loading the GUI, but after I press Button to save some data in the database, it will reach Close () in this event, and it still displays and does nothing. You cannot use X, or ALT + F4. I can get around the GUI and select other values ββfor the ComboBox without any problems.
I invoke the GUI as follows:
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 cannot close the GUI, I can work with the main gui too. I can open the same GUI and after opening a new GUI I can quickly close it. The GUI is very simple with several ComboBoxes , TextBoxes and one EditButton from Devexpress.
Edit: varDocumentsGuiPortfele_FormClosed code allows me to update the GUI (reload the ListView depending on where the user is now).
private void varDocumentsGuiPortfele_FormClosed(object sender, FormClosedEventArgs e) { TabControl varTabControl = tabControlKlientPortfele; if (varTabControl.TabPages.IndexOf(tabPageDokumentyPerKlient) == varTabControl.SelectedIndex) { loadTabControlKlientPortfeleBezZmianyUmowy(); } }