I have a program in which I show a (System.Windows) MessageBox on an event but it doesn't show up. Please notice that I am pretty sure that this worked on a previous update of VS2019 but not on Version 16.11.5 and on VS2022RC.
I have also searched for some hints but nothing came out. So either I did some blatant mistake or this is something new.
I don't think I can provide any other additional information for I think that this might be misleading.
Thanks for helping Patrick
CodePudding user response:
MessageBox.Show(string)
and any of it's overloads that do not take a IWin32Window
create a non-modal window. This message box then may show up behind other windows or eventually not at all (not sure why the later, but maybe it's outside the screen or so). To prevent that, always use an overload with IWin32Window
as first argument. In a simple WinForms app, this is typically the form calling the Show()
method, so the argument can just be this
.
TL;DR
Change
MessageBox.Show("Message");
to
MessageBox.Show(this, "Message");