I have a form that is set to always ontop. I force this every 500 ms via a timer shown below in code.
The timer is being started from a child thread.
The form has to raise an error sometimes but this is not modal and the users ends having to click it twice – once to make it modal and once to acknowledge it (if they do it fast enough)
The user can also bring up a combobox that is in a panel in the main form but when selecting this, the dropdown becomes clear again, as a result of the timer making the form modal(the same effect as if the user just clicked away from the combobox).
How can i fix the Messagebox that it is modal?
How can i fix the combobox that it continues to list the items within it without clearing
thanks
damo
timer to make form always on top
// Restore the form.
this.Visible = true;
this.TopMost = true;
this.WindowState = FormWindowState.Maximized;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
this.Show();
messagebox
MessageBox.Show(this,"hello world", "myApplication");
Just disable the timer before and reenable after showing the messagebox:
This of course can be in a method so you won’t have to duplicate code:
Since
MessageBox.Showis a blocking command, timer will only be reEnabled after the MessageBox is closed