不要在表格旁边单击,而不要关闭前面的表格 [英] Not click out side the form while front form not closed

查看:73
本文介绍了不要在表格旁边单击,而不要关闭前面的表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...朋友,我在vb.net中有一个窗口表单,我在单击form1的按钮时显示了另一个表单,然后显示了form2,但是问题是,如果我单击form1,则最小化了form2,所以有什么技巧吗?用户在关闭form2之前无法单击form1,我使用以下代码在单击按钮时显示form2

hi... friends I have a window form in vb.net I show another form on button click of form1 and then form2 is display but the problem is that if I click on form1 then the form2 minimized is there any technique so the user cannot click on form1 till he close the form2 I use the following code to show the form2 on button click

Private Sub btn_Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Search.Click
        Dim f As New form2()
        f.Show()
 End Sub


另一件事是它应该显示在form1的中央,请帮助我..

在此先感谢
Parveen Rathi


and one another thing is that it should be displayed in the center of form1, please help me..

thanks in advance
Parveen Rathi

推荐答案

使用Form.ShowDialog代替Form.Show.


您应该将表单显示为模态对话框,例如这个:-

You should show the form as a Modal dialogue like this:-

Private Sub btn_Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Search.Click
        Dim f As New form2()
        f.ShowDialog()
        ...
        ... Code to process form results
        ...
        f.Dispose()
 End Sub



然后,您的用户必须先关闭form2,然后才能再次使用form1.

希望这会有所帮助

不要忘记处理ShowShow所显示的表单. -DSK [/EDIT]



Then your user must close the form2 before using form1 again.

Hope this helps

Don''t forget to Dispose a form shown with ShowDialog. - DSK[/EDIT]


这篇关于不要在表格旁边单击,而不要关闭前面的表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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