formclosing

JQGrid Edit Form Closing When Click Off Form

隐身守侯 提交于 2020-01-15 07:58:07
问题 hopefully this is a simple question. In the JQGrid form edit mode, the edit form pops up in the middle of the screen for editing. When I click off of the form, like on the background area, the form closes like I clicked "cancel". I know I can use the "onClose" event to catch this, but I am wondering how I tell the grid not to close unless you click the "cancel" button. I want the editing form to stay there if you click off the form, just close if you click cancel. I guess I am being a bit

Awaiting Asynchronous function inside FormClosing Event

你说的曾经没有我的故事 提交于 2020-01-08 21:51:54
问题 I'm having a problem where I cannot await an asynchronous function inside of the FormClosing event which will determine whether the form close should continue. I have created a simple example that prompts you to save unsaved changes if you close without saving (much like with notepad or microsoft word). The problem I ran into is that when I await the asynchronous Save function, it proceeds to close the form before the save function has completed, then it comes back to the closing function

“e.Cancel ” in formclosing Event

末鹿安然 提交于 2019-12-31 17:11:14
问题 When using the FormClosing event, why does the code e.Cancel = true; work, but new CancelEventArgs().Cancel = true; does not work? private void Form1_FormClosing(object sender, FormClosingEventArgs e) { e.Cancel = true; new CancelEventArgs().Cancel = true; } 回答1: The event is raised by the Winforms plumbing code. The only way it can see that the custom event handler wants to alter the default behavior is through the e object. Creating a new CancelEventArgs object has no side-effects that the

“e.Cancel ” in formclosing Event

时光毁灭记忆、已成空白 提交于 2019-12-31 17:10:42
问题 When using the FormClosing event, why does the code e.Cancel = true; work, but new CancelEventArgs().Cancel = true; does not work? private void Form1_FormClosing(object sender, FormClosingEventArgs e) { e.Cancel = true; new CancelEventArgs().Cancel = true; } 回答1: The event is raised by the Winforms plumbing code. The only way it can see that the custom event handler wants to alter the default behavior is through the e object. Creating a new CancelEventArgs object has no side-effects that the

delay Application Close best practice?

痴心易碎 提交于 2019-12-24 19:23:31
问题 Is there a better way to handle the task of doing something after the user has chosen to exit a WinForms program than this : [edit 1 : in response to comment by 'NoBugz ] In this case there is no ControlBox on the Form , and there is a reason for putting one level of indirection in what happens when the user chooses to close the Form [/edit 1] [edit 2 : in response to all comments as of GMT +7 18:35 January 20 ] Perhaps using fading out the MainForm is a simple illustration of what you might

Is There a Way to Remove the Delay between an Interspersed Login form and the Main form?

邮差的信 提交于 2019-12-13 04:47:16
问题 Following the suggestion here to create my login form in the project's Main method like so: [MTAThread] static void Main() { AppDomain.CurrentDomain.UnhandledException += Unhandled; frmLogin loginForm = new frmLogin(); if (loginForm.ShowDialog() != DialogResult.OK) { // If they hit "Close" just use the default values for now (for testing) HHSConsts.userName = "duckbilled"; HHSConsts.pwd = "platypus"; HHSConsts.currentSiteNum = "Packers20Seahawks19"; } else { HHSConsts.userName = loginForm

Is DoEvents() also evil in FormClosing?

倾然丶 夕夏残阳落幕 提交于 2019-12-10 10:35:20
问题 On a different question I suggested to use private void Form1_FormClosing(object sender, FormClosingEventArgs e) { while (processingLock) Application.DoEvents(); } in the FormClosing event (with processingLock becoming false immediately after a lengthy calculation was done). It should serve the purpose to have the application close down in an orderly manner and the original poster didn't use threads. On my suggested answer somebody commented that DoEvents is never good, providing this link:

How to prevent closing of a HIDDEN form in C#

ⅰ亾dé卋堺 提交于 2019-12-10 00:10:39
问题 I want to prevent closing of a form in some cases. I know the usage of OnFormClosing, but when the form is hidden (Visible==false), the OnFormClosing method is not called. Is there a way to intercept form closing in this case? Edit (some more details): The form is a child in a MdiParent, should stay invisible in the background and wait for calls from another thread (by Invoke). The MdiParent closes all child windows when the user "disconnects", in this case the above form should stay open,

VB.NET: Abort FormClosing()

故事扮演 提交于 2019-12-09 03:01:05
问题 I have a code snippet that I want to run when the app is closing. So, I used FormCLosing event. But now i wanna place a confirmation message for exiting. Like, if the user clicks the Exit( X ) button, there'll be a prompt, if he clicks NO, then the app will not close and revert to previous state. Now I find that hard to achieve using FormClosing event. because it'll get executed no matter what button the user clicks. Any remedy for that? I mean, I need an even like ExitButtonPressed() .. 回答1:

How to close form in C#

杀马特。学长 韩版系。学妹 提交于 2019-12-08 15:07:48
问题 Ok, so a Windows Forms class, WindowSettings, and the form has a "Cancel"-button. When the user clicks the button, the dialog DialogSettingsCancel will pop-up up and ask the user if he is sure he wants to perform the action. The dialog has 2 buttons, a "Yes"-button and a "No"-button. If the user clicks the "Yes"-button, I want both DialogSettingsCancel and WindowSettings to be closed. My button_Click event handler in DialogSettingsCancel: private void button1_Click(object sender, EventArgs e)