VB.net 中的 MessageBox 持久化
我使用 MessageBox
向用户提供一些信息,但是当弹出这样的框时,我希望它阻止对主窗口的访问。因此,在用户单击“确定”之前,他们不应该能够单击(甚至无法聚焦)其下方的窗口。
有人知道该怎么做吗?我注意到 MessageBox
的功能很少,所以也许我什至必须为此使用不同的对象。
I'm using MessageBox
to give some information to the user, but when such a box pops up, I want it to block access to the main window. So, until the user has clicked "OK", they should not be able to click (or even focus on) the window that's below it.
Does anybody know how to do this? I've noticed that MessageBox
has very few functions, so maybe I'll even have to use a different object for this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一个快速但肮脏的解决方案可能是对话框表单(项目->添加 Windows 窗体->对话框)。这为您提供了 MessageBox 的视觉可扩展性。
您可以调用 MessageBox 的 ShowDialog 方法,它当然会阻止对父窗口的访问。
当然还有其他方法。
例子:
A quick and dirty solution could be a dialog form (Project->Add Windows Form->Dialog). This gives you visual extensibility of your MessageBox.
You can call your MessageBox's ShowDialog method and it will of course block access to the parent window.
There are of course other methods.
Example:
就在我发帖后,我的朋友就给出了答案。通过调用
MessageBox.Show(mf, "text")
(其中 mf 是主窗体),只要未单击“确定”按钮,mf 就会被禁用。我想发布这个问题毕竟有点愚蠢,但我希望它可以帮助其他遇到同样问题的人。Just after I posted here, my friend came up with the answer. By calling
MessageBox.Show(mf, "text")
where mf is the main form, mf will be disabled as long as the OK button has not been clicked. I suppose this question was a bit silly to post after all, but I hope it might help others if they're stuck with the same problem.