问题描述
我在处理 showdialog 表单时遇到了 showdialog 问题.应用程序焦点到在任务栏中打开的另一个程序.如果什么都没有打开,那么它会聚焦到桌面.
I have a problem with showdialog when the showdialog form is being disposed. The Application focus to another program opened in taskbar. if nothing is opened then it focused to desktop.
推荐答案
当对话框过早处理时会发生这种情况.所有窗口都被对话框禁用,因此 Windows 无法将焦点集中在其中任何一个上,而必须选择另一个应用程序的窗口.确保使用带有 Using 关键字的标准模式,以便对话框对象在 关闭后被释放:
This will happen when the dialog is getting disposed too early. All of the windows are disabled by the dialog so Windows can't keep the focus on any of them and has to pick the window of another app. Make sure you use the standard pattern with the Using keyword so the dialog object is disposed after it closes:
Using dlg As New FooDialog
If dlg.ShowDialog(Me) = DialogResult.OK Then
'' Use dlg properties
''
End If
End Using
这篇关于showdialog.dispose 焦点到另一个打开的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!