第二个窗体在Visual Builder上无法正确加载?

时间:2017-09-08 00:31:47

标签: vb.net winforms constructor

在第一个表单中我有一个文本框,您可以在其中添加您的姓名,然后当您单击下一个窗口时,将弹出第二个表单,说我的名字是:您的姓名。这很好,但是我怎么能够将名为OtherForm的第二个表单的名称更改为我的姓名,以便当第二个表单弹出时,在左上角我的名字会出现而不是OtherForm?这是到目前为止第一个和第二个表单的代码。

主要表格代码:

Public Class MainForm

Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles 
MyBase.Load

End Sub

Public Sub Label1_Click(sender As Object, e As EventArgs) Handles 
WindowName.TextChanged




End Sub

Public Sub WindowName_TextChanged(sender As Object, e As EventArgs)

End Sub

Public Sub OffButton_Click(sender As Object, e As EventArgs) Handles 
OffButton.Click
    Me.Close()


End Sub

Public Sub NextButton_Click(sender As Object, e As EventArgs) Handles 
NextButton.Click
    OtherForm.NameLabel.Text = WindowName.Text
    OtherForm.Show()
End Sub
End Class

第二种形式称为OtherForm

Public Class OtherForm

Public Sub CloseButton_Click(sender As Object, e As EventArgs) Handles 
CloseButton.Click
    Me.Close()
End Sub

Public Sub OtherForm_Load(sender As Object, e As EventArgs) Handles 
MyBase.Load

End Sub

Public Sub NameLabel_Click(sender As Object, e As EventArgs) Handles 
NameLabel.Click


End Sub

Private Sub Label1_Click(sender As Object, e As EventArgs) Handles 
Label1.Click

End Sub
End Class

1 个答案:

答案 0 :(得分:0)

尝试

OtherForm.Text = WindowName.Text

设置表单的标题。或者您可以将文本设置为您想要的任何内容。我不确定你的意思是“我的名字”还是你输入的名字。

如果您的意思是“我的名字”,那么您可以在“文本”的表单属性中输入它,而不是在代码中输入。