这么简单的事情导致我把头发拔了。...
我要做的就是将子窗体上的输入值传递回父窗体,或者传递给Public变量或文本框,但是该值不会传递回来。
父母表格代码:
Private Sub cmb_pay_type_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmb_pay_type.SelectedIndexChanged
If cmb_pay_type.SelectedItem = "شيك" Then
Dim frm As New cheque_sent_add
frm.XX.Text = 1
frm.txt_cheque_value.Text = DFANEW.Text
frm.txt_cheque_holder_name.Text = MORD.Text
frm.txt_cheque_holder_phone.Text = PON.Text
frm.ShowDialog()
End If
End Sub
Public cheque_num As String
Public cheque_value As String
Public due_date As Date
Public bank_name As String
Public bank_branch As String
Public status As String
Public cheque_owner As String
Public cheque_holder_name As String
Public cheque_holder_phone As String
Public action_date As Date
Public note As String
Public insert As Boolean = False
和子表格:
If XX.Text = 1 Then
DFAM.DFANEW.Text = txt_cheque_value.Text
DFAM.cheque_num = txt_cheque_num.Text
DFAM.cheque_value = txt_cheque_value.Text
DFAM.due_date = due_date.Value.ToString("dd/MM/yyyy")
DFAM.bank_name = txt_bank_name.Text
DFAM.bank_branch = txt_bank_branch.Text
DFAM.status = cmb_status.SelectedItem
DFAM.cheque_owner = txt_cheque_owner.Text
DFAM.cheque_holder_name = txt_cheque_holder_name.Text
DFAM.cheque_holder_phone = txt_cheque_holder_phone.Text
DFAM.action_date = action_date.Value.ToString("dd/MM/yyyy")
DFAM.note = txt_note.Text
DFAM.DFANEW.Enabled = False
DFAM.insert = True
Me.Close()
Exit Sub
End If
这是我正在使用的,如果我打开一个新的“父”表单,我可以显示数据, 放我想从孩子的值发送回已经打开的父窗体。
答案 0 :(得分:-1)
在尝试并尝试了许多方法之后,这就是我解决问题的方式
将模块添加到解决方案
然后添加公共变量
Module Module1
Public x1 As String
Public x2 As String
End Module
主要形式Form1
:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim f2 As New Form2
f2.ShowDialog()
End Sub
End Class
最后是子表单Form2
:
Public Class Form2
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
x1 = TextBox1.Text
x2 = TextBox2.Text
Form1.TextBox1.Text = x1
Form1.TextBox2.Text = x2
Me.Close()
End Sub
End Class