Private Sub Button1_Click(_ ByVal sender As System.Object,_ ByVal e As System.EventArgs _ )处理Button1.Click 如果myform是Nothing那么 myform = New Form2()''myform.MdiParent =我 AddHandler myform.Closed,AddressOf Me.ChildForm_Closed myform.Show()其他' 'MsgBox(表格已打开:& myform.Text) Me.ActivateMdiChild(myform)''Ungetestet:Evtl。 funktioniert ''das nicht,da dieMethodefürdie''interne Infrastruktur dient。结束如果 End Sub Private Sub ChildForm_Closed(_ ByVal发送者作为对象,_ ByVal e As System.EventArgs _ )处理MyBase.Closed myform = Nothing 结束子 /// - Herfried K. Wagner [MVP] < http://www.mvps.org/dotnet> Hi All,I have my MDI form and 10 child forms, I call the child form on the clickevent from the menu usingDim NewChildFrm As New newCustomerForm NewChildFrm.MdiParent = Me NewChildFrm.Show() What can I prevent to open another newCustomerForm from the menu? if isalready one and open just got focus on the form. Tks in advance JFB 解决方案 \\\Private myform As Form2 Private Sub Button1_Click( _ByVal sender As System.Object, _ByVal e As System.EventArgs _) Handles Button1.ClickIf myform Is Nothing Thenmyform = New Form2()''myform.MdiParent = MeAddHandler myform.Closed, AddressOf Me.ChildForm_Closedmyform.Show()Else''MsgBox("Form already open: " & myform.Text)Me.ActivateMdiChild(myform) '' Ungetestet: Evtl. funktioniert'' das nicht, da die Methode für die'' interne Infrastruktur dient.End IfEnd Sub Private Sub ChildForm_Closed( _ByVal sender As Object, _ByVal e As System.EventArgs _) Handles MyBase.Closedmyform = NothingEnd Sub/// --Herfried K. Wagner [MVP]<http://www.mvps.org/dotnet> http://groups.google.com/groups?thre...tngp13.phx.gbl--Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html \\\ Private myform As Form2 Private Sub Button1_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs _ ) Handles Button1.Click If myform Is Nothing Then myform = New Form2() ''myform.MdiParent = Me AddHandler myform.Closed, AddressOf Me.ChildForm_Closed myform.Show() Else ''MsgBox("Form already open: " & myform.Text) Me.ActivateMdiChild(myform) '' Ungetestet: Evtl. funktioniert '' das nicht, da die Methode für die '' interne Infrastruktur dient. End If End Sub Private Sub ChildForm_Closed( _ ByVal sender As Object, _ ByVal e As System.EventArgs _ ) Handles MyBase.Closed myform = Nothing End Sub /// -- Herfried K. Wagner [MVP] <http://www.mvps.org/dotnet> 这篇关于MDI表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-10 12:32