Vb.net 如何从sa MDI表单Groupbox获取文本框的值?

Vb.net 如何从sa MDI表单Groupbox获取文本框的值?,vb.net,rdlc,mdichild,mdiparent,Vb.net,Rdlc,Mdichild,Mdiparent,我是vb.net新手,总是在寻找解决方案。我的表单包括主菜单、poCustom和rdlcForm。在我使用MDI表单获得新外观之前,所有这些都工作正常 我的“新”主菜单现在将poCustom包含在一个Groupbox中。我在代码中搜索到 For Each f As Form In Application.OpenForms If TypeOf f Is poCustom Then f.Activate() Return

我是vb.net新手,总是在寻找解决方案。我的表单包括主菜单、poCustom和rdlcForm。在我使用MDI表单获得新外观之前,所有这些都工作正常

我的“新”主菜单现在将poCustom包含在一个Groupbox中。我在代码中搜索到

    For Each f As Form In Application.OpenForms
        If TypeOf f Is poCustom Then
            f.Activate()
            Return
        End If
    Next

    Dim ch As New poCustom
    ch.TopLevel = False
    ch.Visible = True

    ch.StartPosition = FormStartPosition.Manual
    Dim leftStart As Integer = 1220 - (ch.Width + (SystemInformation.Border3DSize.Width * 2))
    Dim topStart As Integer = 670 - (ch.Height + (SystemInformation.Border3DSize.Height * 2))

    ch.Location = New Point(leftStart, topStart)

    GroupBox1.Controls.Add(ch)
问题:rdlcForm(报表)无法获取poCustom表单中文本框的值。代码如下:

 Private Sub rptPOView2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim rptParam1(11) As Microsoft.Reporting.WinForms.ReportParameter
    rptParam1(0) = New Microsoft.Reporting.WinForms.ReportParameter("rptDate", poCustom.Label1.Text)
    rptParam1(1) = New Microsoft.Reporting.WinForms.ReportParameter("rptREF", poCustom.Label5.Text)
    rptParam1(2) = New Microsoft.Reporting.WinForms.ReportParameter("rptCompany", poCustom.CompanyName.Text)
    rptParam1(3) = New Microsoft.Reporting.WinForms.ReportParameter("rptQTY", poCustom.txBoxQTY.Text)
    rptParam1(4) = New Microsoft.Reporting.WinForms.ReportParameter("rptUOM", poCustom.txBoxUOM.Text)
    rptParam1(5) = New Microsoft.Reporting.WinForms.ReportParameter("rptDesciption", poCustom.txBoxDesc.Text)
    rptParam1(6) = New Microsoft.Reporting.WinForms.ReportParameter("rptUnit", poCustom.txBoxUnit.Text)
    rptParam1(7) = New Microsoft.Reporting.WinForms.ReportParameter("rptTotal", poCustom.txBoxTotal.Text)
    rptParam1(8) = New Microsoft.Reporting.WinForms.ReportParameter("rptSubTotal", poCustom.Label25.Text)
    rptParam1(9) = New Microsoft.Reporting.WinForms.ReportParameter("rptVAT", poCustom.Label26.Text)
    rptParam1(10) = New Microsoft.Reporting.WinForms.ReportParameter("rptTotalAmount", poCustom.Label27.Text)
    rptParam1(11) = New Microsoft.Reporting.WinForms.ReportParameter("rptRequest", poCustom.Label30.Text)

    ReportViewer1.LocalReport.SetParameters(rptParam1)
    Me.ReportViewer1.RefreshReport()

    TextBox1.Text = poCustom.CompanyName.Text
End Sub

这在不使用MDI表单的情况下正好起作用。我想知道问题的原因,以便将来使用。提前谢谢你

您正在使用两个不同的
poCustom
实例
ch
是第一个,您可以填充它的文本框。但是在
rptPOView2_Load
事件中,您使用的是另一个实例,其中包含的文本框还没有值。解决此问题的一种方法是使用
poCustom
本身,而不是
ch

poCustom.TopLevel  = False
poCustom.Visible = True

poCustom.StartPosition = FormStartPosition.Manual
Dim leftStart As Integer = 1220 - (ch.Width + (SystemInformation.Border3DSize.Width * 2))
Dim topStart As Integer = 670 - (ch.Height + (SystemInformation.Border3DSize.Height * 2))

poCustom.Location = New Point(leftStart, topStart)

GroupBox1.Controls.Add(poCustom)

什么是
poCustom
?您是否应该使用
POForm
而不是
poCustom
,例如
ReportParameter(“rpdate”,POForm.Label1.Text)
对不起,我有两种采购订单表单,poDefault和poCustom。对不起,我会更新我的问题。我认为您使用的是不同的poCustom实例