2012年5月8日 星期二

動態call form


Private Sub ShowForm(ByVal FormName As String)
        Dim ProjectName As String =
        Reflection.Assembly.GetExecutingAssembly.GetName.Name
        Try
            Dim tyOfStringVariable As Type = Type.GetType(ProjectName & "." &
            FormName)
            Dim frmObject As Object = Activator.CreateInstance(tyOfStringVariable)
            DirectCast(frmObject, Form).StartPosition =
            FormStartPosition.CenterParent
            DirectCast(frmObject, Form).ShowDialog()
        Catch ex As Exception
            ' TODO
        End Try
    End Sub

沒有留言:

張貼留言