Any idea why a dialog box would stay displayed even after the "yes" button has been clicked
I have an application that prompts the user if they want to proceed with a process which results in numerous database changes.
After they select "yes" the message box stays visible even after the resulting code executes...
Doesn't look very professional at all.
MRW

Dialog box stays visible after "Yes" button clicked
tamccann
Alex1123123
Thanks. Will try this. Philosophically one would assume that this level of functionality should be handled by Windows itself i.e. making sure one form does not adversely impact on the display of another
Why does the MessageBox not do its own "Application.DoEvents()
MRW
Jimmy Bogard
Hello again.
The idea is that long running tasks shall run in a worker thread, not in the event-handler itself. This will make it possible to eg. cancel the task or see how it does.
Programming with forms make programming database soutions look easy. It is not. To set up deployment, handle security, offer the right functionality at the right time and handle long-running tasks takes a lot of experience and many iterations. .NET 2.0 makes it easier then ever, but it is still not easy.
Have a look at BackgroundWorker. Be aware that handling GUI gets more complex the moment you do this.
Play with the features first. To get some experience with it. Then put it in a project.
Hope this helps
stebe000
Hi.
The usual suspect is the form repaint. It is a case of the window behind the message box not repainting the area where the message box where. To allow your form to repaint this area immediatly you can call
Application.DoEvents()
after the user replies "yes" to your message box.
Hope this helps
Thomas Roethlisberger
Yes, I am using the .Show. Below is the snippet.
UserSelection = MessageBox.Show(
"ReMake this order ", "Confirm remake", MessageBoxButtons.YesNo, _MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
If Not UserSelection = DialogResult.Yes Then Me.ToolStripStatusLabel2.Text = "Remake cancelled" Return Else Me.ToolStripStatusLabel2.Text = "Remaking..." End If