2014-04-15 32 views
2

我是vb.net的新手,一直在尋找解決方案。我涉及的表單是MainMenu,poCustom和rdlcForm。所有工作都很好,直到我用MDI表格重新煥然一新。如何從sa MDI表單Groupbox獲取文本框的值?

我的「新」MainMenu現在將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 Forms的情況下工作。我想知道未來使用問題的原因。先謝謝你!

+0

什麼是'poCustom'?並且不應該使用'POForm'而不是'poCustom',例如'ReportParameter(「rptDate」,POForm.Label1.Text)' – Arman

+0

非常抱歉,我有兩種形式的Purchase Order,poDefault和poCustom。我會更新我的問題對不起。 – user3214105

+0

我想你正在使用不同的poCustom實例 – Arman

回答

1

您正在使用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)