---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()
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
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
参考了一下,得出下面的代码
<!-- 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()
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()
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
本文介绍了如何在MDI窗体中使用ToolBar实现多窗体的实例操作。通过具体的VB.NET代码示例,展示了如何利用ToolBar按钮触发窗体的显示,并确保了窗体的实例化仅发生一次。
1062

被折叠的 条评论
为什么被折叠?



