如何prevent的WinForms失去焦点? [英] How to prevent WinForms from losing focus?

查看:140
本文介绍了如何prevent的WinForms失去焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何prevent我的关于表格(无输入框,OK按钮只)失去焦点,迫使用户点击OK?我试图验证和ErrorProvider。我想也委派显示,激活和Focus这样的:

How to prevent my "About-Form" (no input-boxes, OK-button only) from losing focus, to force the user to click "OK"? I tried Validation and ErrorProvider. I tried also to delegate Show, Activate and Focus like this:

AboutForm myAboutForm = new AboutForm();
myAboutForm.Deactivate += delegate { myAboutForm.Show(); myAboutForm.Activate(); };
myAboutForm.Show();

但没有任何工程。

but nothing works.

推荐答案

请您对形成模态窗口对话框。

Make your about form a Modal window dialog.

AboutForm myAboutForm = new AboutForm();
myAboutForm.ShowDialog();

从MSDN - <一个href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.showdialog.aspx"><$c$c>ShowDialog:

显示窗体作为模式对话框。

Shows the form as a modal dialog box.

这篇关于如何prevent的WinForms失去焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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