---MDI窗体和多窗体编程--- 目的:在MDI窗体内用ToolBar实现多窗体的实例,在VB.NET中显示窗体一般代码如下
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->
Private
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
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
参考了一下,得出下面的代码
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->
这样就实例了一次窗体~ ---end---
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->
Private Shared fr As New frmName
Private 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
Private Shared fr As New frmName
Private 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