msgbox在特定时间后自动消失 [英] msgbox that disappears automatically after certain time

查看:602
本文介绍了msgbox在特定时间后自动消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


vb.net中是否有任何类型的msgbox可以发出消息并在特定时间后自动消失?
还是有任何方法可以隐藏msgbox,而无需用户单击确定"?

谢谢
Furqan

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

推荐答案

本身,不,因为该消息框在主UI线程上运行.它是一个对话框,从本质上来说,它是一个阻止操作.您将必须编写一个自定义对话框,该对话框可以在一段时间后自动关闭.当对话框显示时,启动一个计时器,该计时器设置为您要在此之后关闭对话框的持续时间,在计时器事件中,请关闭对话框.
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.


除非您想做一个模拟键盘输入的肮脏技巧(不,这不是我的建议;对不起,如果我给您这个想法,那将是很糟糕的:-)).

您可以创建一个自定义表单或窗口(您未标记UI;请参阅我对问题的评论),而不是MessageBox.在这种情况下,您可以将其作为 模式 表单或窗口运行(多么不便!请始终标记您的UI库!),使用计时器调用HideClose它.

我可能会警告您:这会违反预期的UI设计风格,并且可能会激怒用户.如果某件东西具有确定"和/或取消"按钮,则用户期望是决定何时关闭它的人.考虑使用类似ToolTip之类的东西,或使用行为类似于ToolTip的控件.

—SA
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


您可以为此创建自己的消息框表单.重载采用消息文本和超时值的构造函数.在Form Load上编写一些逻辑,该逻辑将显示一条消息,直到超时值,然后自动关闭.
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.


这篇关于msgbox在特定时间后自动消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆