vbnet2窗体 vbnet mdi窗体

VB.net 两个窗体之间传递参数新窗体中写
构造函数
,然后调用 。
比如你要调用的新窗体是From1.cs这个窗体 ,
public
Form1(要传入的参数)
{
//把传入的参数传入窗体中
//执行窗体标准内容
}
然后在需要调用的地方调用
Form1
f
=
new
Form1(传出的参数);
'--------Form1--------
Dim
f2
As
Form2
Private
Sub
Command1_Click()
Set
f2
=
New
Form2
f2.Show
vbModal
End
Sub
'--------Form1
End--------
'--------Form2--------
Dim
WithEvents
f3
As
Form3
Private
Sub
Command1_Click()
Set
f3
=
New
Form3
f3.Show
End
Sub
Public
Sub
f3_f2W()
Me.Command1.Caption
=
"f2W"
End
Sub
'--------Form2
End--------
'--------Form3--------
Public
Event
f2W()
Private
Sub
Command1_Click()
RaiseEvent
f2W
End
Sub
'--------Form3
End--------
f.Show();
如此就能实现调用了 。
vb.net如何让两个窗体并发运行Imports System.Threading
Public Class Form1
Dim t1, t2 As Thread
Dim tt1
Private Delegate Sub voiddelegate(ByVal i As Integer)
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Form2.Show()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
t1 = New Thread(AddressOf test)
tt1 = 1
t1.Start()
tt1 = 2
t2 = New Thread(AddressOf test)
t2.Start()
' Timer1.Start()
End Sub
Private Sub updateui(ByVal i As Integer)
Form2.Label1.Text = i.ToString
Form2.Label2.Text = i.ToString
End Sub
'把循环放到线程中运行会好一些vbnet2窗体,其实主要事务是对窗体控件的操作时多线程意义不大vbnet2窗体 , 因为访问窗体的代码依然要在窗体线程中运行 。
Private Sub test()
Dim d As voiddelegate = AddressOf updateui
For i = 0 To 9000
Me.Invoke(d, i)
Next
End Sub
'如果放在计时器中运行效果好的多
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Static i As Integer = 0
i= 1
If i9000 Then Timer1.Stop() : i = 0
Form2.Label1.Text = i.ToString
Form2.Label2.Text = i.ToString
End Sub
End Class
'如果在另一线程中用Application.run 打开窗体确实能行vbnet2窗体,不过窗体间相互操作不起作用,这个尚待研究中 。
如何给VB.NET窗体添加子窗体?直接添加一个MID父窗体或在已有窗体的属性中找到IsMDIContainer属性 , 然后设置为True,然后创建第二个窗体 ,需要加载子窗体的时候:
Dim NewMDIChild As New Form2
NewMDIChild.MdiParent = Me
NewMDIChild.Show()
Public Shared Sub CheckMDIChildForm(ByVal MDIForm As Windows.Forms.Form, ByVal MDIChildForm As Windows.Forms.Form, ByVal MDIChildFormName As String)
If MDIForm.MdiChildren.Length1 Then
'如果没有任何一个MDI子窗体,则创该MDI子窗体的窗体实例
Dim MDIChildFrm As Windows.Forms.Form = MDIChildForm ' 定义MDI子窗体
MDIChildFrm.MdiParent = MDIForm '指定父窗体
MDIChildFrm.Show() '打开窗体
Exit Sub
Else
Dim x As Integer
Dim frmyn As Boolean
For x = 0 To (MDIForm.MdiChildren.Length) - 1
【vbnet2窗体 vbnet mdi窗体】Dim tempChild As Windows.Forms.Form = CType(MDIForm.MdiChildren(x), Windows.Forms.Form)
If tempChild.Name = MDIChildFormName Then
'检测到有该MDI子窗体 , 设为激活 并退出循环
frmyn = True
tempChild.BringToFront()
Exit For
Else
frmyn = False
End If
Next
If Not frmyn Then
'在打开的窗体中没检测到则新建
Dim MDIChildFrm As Windows.Forms.Form = MDIChildForm ' 定义MDI子窗体
MDIChildFrm.MdiParent = MDIForm '指定父窗体
MDIChildFrm.Show() '打开窗体
End If
End If
End Sub
vbnet2窗体的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vbnet mdi窗体、vbnet2窗体的信息别忘了在本站进行查找喔 。

    推荐阅读