Click here to Skip to main content
15,909,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Is there any type of msgbox in vb.net that gives a message and disappears automatically after a certain time?
Or is there any method to hide the msgbox, without user's clicking OK?

Thanks
Furqan
Posted
Comments
Sergey Alexandrovich Kryukov 28-Jun-11 12:38pm    
Tag it! WPF, Forms, what?!
--SA

You can use Windows Script Host Object Model to accomplish the same.

Windows Script Host Popup Method[^]

Windows Script Host[^]
 
Share this answer
 
Not really unless you want to do a dirty trick like simulating keyboard input (no, this is not my advice; sorry if I gave you this idea — it would be pretty bad :-)).

You could create a custom form or window (you did not tag you UI; please see my comment to the question) instead MessageBox. In this case, you could run it as a modal form or window (how inconvenient! please, always tag your UI library!) use a timer to call Hide or Close it.

I could warn you: this would violate expected UI design style and possible irritate the user too much. Is something has OK and/or Cancel button, the user expect to be the one who decides when to close it. Consider using something like ToolTip instead, or some control which behaves like a ToolTip.

—SA
 
Share this answer
 
You can create your own messagebox form for that. Overload a constructor which takes message text and timeout value. Write some logic on Form Load which will display a message up to timeout value and then after close automatically.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 28-Jun-11 12:44pm    
Correct, my 4 (because I criticized this approach but you did not :-). There is a bit more to it, please see my answer.
--SA
By itself, no - because the messagebox runs on the primary UI thread. It's a dialog so it is, by the very nature of it, a blocking operation. You are going to have to write a custom dialog that can close itself automatically after a period of time. When the dialog gets displayed, kick off a timer that's set to the duration you want to close the dialog after and, in the timer event, close the dialog.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 28-Jun-11 12:43pm    
Correct, my 5. There is a bit more to it, please see my answer.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900