VB.net增加form,vb·net
如何给VB.NET窗体添加子窗体?
直接添加一个MID父窗体或在已有窗体的属性中找到IsMDIContainer属性,然后设置为True,然后创建第二个窗体 ,需要加载子窗体的时候:
长岭ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!
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.Length 1 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
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
vb.net 怎么样新建一个from2
打开Visual Studio,点击文件→新建项,选择“窗体”,在文件名那里输入Form2.vb就得了
vb.net用代码向另一个窗体添加命令按钮
先得到目标窗体的 handle (句柄) 或整个对象, 然后实例化一个button 并加入到窗体对象中. 如: 在 form2 点击 add 按钮后, form1 会新添加一个按钮,单击显示hello , 下面是两个窗口类. public class form1 inherits system.windows.forms.form '这是一个什么都没有的空窗体 public sub new() me.size=new size(200,200) end subend class public class form2 inherits system.windows.forms.form private button1 as button '添加按钮 private frm as form public sub new() me.size=new size(200,200) button1= new button() '实例化 button1.text="add" '名字就叫 add button1.location=new point(50,50) addhandle button1.click, addressof add_click me.controls.add(button1) end sub '用于记录form1对象的属性 public property form1() as form get return frm end get set (byval value as form) frm = value end set end property '添加按钮 private sub add_click(byval o as object, byval e as eventargs) '当form1属性被指定,向form1 添加按钮 if frm isnot nothing then dim btn as button = new button() btn.text ="new button" btn.location=new point(50,50) addhandle btn.click, addressof button_click frm.controls.add (btn) else msgbox ("未指定form1") end if end sub '新按钮的单击事件 private sub button_click(byval o as object, byval e as eventargs) msgbox("hello!") end subend class 两个窗体类完成了,然后在模块写如下代码,程序设置为从模块启动:public module module1 public sub main() dim frm1= new form1() dim frm2 = new form2() frm2.form1=frm1 frm2.show() frm1.show() application.run(frm2) end subend module
vb.net窗体问题form
我按照你的说法写了程序~能正常运行!
========================================
'窗口1的
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.Show()
End Sub
End Class
========================================
’2的
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form3.Show()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form1.Close()
End Sub
End Class
===========================================================
‘3的
Public Class Form3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.Close()
End Sub
End Class
文章标题:VB.net增加form,vb·net
文章分享:http://scyanting.com/article/dsgcocs.html