单击菜单只运行一个子窗体实例的简单方法

类别:.NET开发 点击:0 评论:0 推荐:

    Private m_Form2 As Form2

 

    Private Sub Form2MenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Form2MenuItem.Click

        If m_Form2 Is Nothing OrElse m_Form2.IsDisposed Then

            m_Form2 = New Form2

            m_Form2.MdiParent = Me

            m_Form2.Show()

        Else

            m_Form2.Activate()

        End If

    End Sub

注:以前我是运用通过记录Handle来遍历子窗体的办法.今天看着Dispose,试试能不能利用,果是行的.
不知这样做法有什么弊处.

本文地址:http://com.8s8s.com/it/it43074.htm