Private Function isOpen(ByVal FormName As String) As Boolean isOpen = False Dim i As Int16 Dim Fm() As Form = Me.MdiChildren For i = 0 To UBound(Fm) If UCase(Fm(i).Name) = UCase(FormName) Then Fm(i).BringToFront() isOpen = True Exit For End If Next End Function
foreach( Form child in this.MdiChildren ) {}
//一下功能检测指定的窗体是否已经创建,如果没有就创建BillInput是一个mdi子窗体 BillInput input=null; foreach(Form f in this.MdiChildren) { if(f is BillInput) { input=(BillInput)f; break; } } if(input!=null) { input.Show(); input.Focus(); } else { input=new BillInput(); input.MdiParent=this; input.WindowState=FormWindowState.Maximized; input.Show(); input.Update(); }
isOpen = False
Dim i As Int16
Dim Fm() As Form = Me.MdiChildren
For i = 0 To UBound(Fm)
If UCase(Fm(i).Name) = UCase(FormName) Then
Fm(i).BringToFront()
isOpen = True
Exit For
End If
Next
End Function
{}
BillInput input=null;
foreach(Form f in this.MdiChildren)
{
if(f is BillInput)
{
input=(BillInput)f;
break;
}
}
if(input!=null)
{
input.Show();
input.Focus();
}
else
{
input=new BillInput();
input.MdiParent=this;
input.WindowState=FormWindowState.Maximized;
input.Show();
input.Update();
}