[VB.NET]浅谈MDI窗体的多窗体编程

类别:.NET开发 点击:0 评论:0 推荐:
---MDI窗体和多窗体编程--- 目的:在MDI窗体内用ToolBar实现多窗体的实例,在VB.NET中显示窗体一般代码如下     Private Sub ToolBar1_ButtonClick()Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
        Select Case e.Button.Text
            Case "OK"  '"OK" is ToolBarButton.Text
                Dim fr As New frmName
                fr.MdiParent = Me 'Me is MdiForm
                fr.Show()
        End Select
    End Sub

http://www.chinaaspx.com/club/topic_5_7796.htm

参考了一下,得出下面的代码

    Private Shared fr As New frmName
    Private Sub ToolBar1_ButtonClick()Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
        Select Case e.Button.Text
            Case "OK"  '"OK" is ToolBarButton.Text
                If fr Is Nothing Or fr.IsDisposed Then
                    fr = New frmName
                    fr.MdiParent = Me
                    fr.Show()
                Else
                    fr.MdiParent = Me
                    fr.Show()
                    fr.Focus()
                End If
        End Select
    End Sub这样就实例了一次窗体~ ---end---

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