Vb.Net开放表格方法 [英] Vb.Net Open Form Method

查看:106
本文介绍了Vb.Net开放表格方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何防止以mdi格式打开多个相同的表单。我如何在文本框中打开表单名称?谢谢。

解决方案

创建表单时,检查 My.Application.OpenForms 中的所有表单,看看是否表单已经打开,如果是,只需调用 .Activate 就可以将它带到前面。



至于在文本框中打开带有文本的表单,如果您想要一个真正通用的解决方案,这将更加困难并需要反思。否则,您可以使用 Select Case 语句根据文本框中输入的内容选择正确的表单:



 选择 案例 mytextbox.Text 
案例 FormA
打开表单A
案例 FormB
' 打开表格B
结束 选择


如果您认为您需要在MDI应用程序中执行此操作,请使用MDI将其设计用于并且可能不应该是完全使用MDI。


我找到了表格来检查是否有空的。



首先,在公共模块中定义了变量。

当我打电话表格,代码如下:

 如果 FormSlipGiris.IsDisposed =  True  然后 
FormSlipGiris = FrmSlipGiris
FormSlipGiris .MdiParent = FrmMDI
FormSlipGiris.Text = SlipGiriş
FormSlipGiris。 Show()
ElseIf FormSlipGiris.Visible = True 然后
' MsgBox(FormZatenAçık!)
FormSlipGiris.BringToFro nt()
FormSlipGiris.UyeNo。选择()
其他
FormSlipGiris.MdiParent = FrmMDI
FormSlipGiris.Text = SlipGiriş
FormSlipGiris.Show()
结束 如果


How to prevent the opening of more than one of the same form in mdi form. And How Can I open a form name as in textbox? Thanks.

解决方案

When creating the form, check all the forms in My.Application.OpenForms to see if the form is already open, if it is, just call the .Activate on it to bring it to the front.

As for opening a form with the text in a textbox, this is more difficult and requires reflection if you want a truely universal solution. Otherwise you could use a Select Case statement to choose the right form based on whatever is typed into the textbox:

Select Case mytextbox.Text
    Case "FormA"
      'Open Form A
    Case "FormB"
      'Open Form B
End Select


If you think you need to be doing this in an MDI application, yuo're using MDI for a purpose it wasn't designed for and probably shouldn't be using MDI at all.


I found the form to check if there is an open.

First, has defined variables in Public Module.
When I call the form, code is as follows:

If FormSlipGiris.IsDisposed = True Then
                   FormSlipGiris = New FrmSlipGiris
                   FormSlipGiris.MdiParent = FrmMDI
                   FormSlipGiris.Text = "Slip Giriş"
                   FormSlipGiris.Show()
               ElseIf FormSlipGiris.Visible = True Then
                   '    MsgBox("Form Zaten Açık!")
                   FormSlipGiris.BringToFront()
                   FormSlipGiris.UyeNo.Select()
               Else
                   FormSlipGiris.MdiParent = FrmMDI
                   FormSlipGiris.Text = "Slip Giriş"
                   FormSlipGiris.Show()
               End If


这篇关于Vb.Net开放表格方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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