简体   繁体   English

为什么我无法将表单文本框中的数据传递到面板VB.NET中的表单文本框中

[英]Why i can't pass data from form textbox to form textbox inside panel VB.NET

This is the code when calling form and showing inside panel 这是调用表单并显示内部面板时的代码

 Dim frmLubesInterface As LubesInterface = New LubesInterface
      with frmLubesInterface 
            .Text = "frmLubesInterface"
            .TopLevel = False
             Panel6.Controls.Add(frmLubesInterface)
            .StartPosition = 
            .FormStartPosition.CenterScreen
            .Show()
     end with

This is code passing data from form and show inside form which is inside of panel 这是代码从表单传递数据并显示在面板内部的表单内部

 Dim Itemname as string = ""
     Itemname = txtItemNameSearch.Text
     LubesInterface.txtItem.Text = Itemname - **this part is where i pass the value of data to form textbox inside panel**

To summary i can't pass the value of textbox to form textbox inside the panel, but when showing it as msgbox it show the value. 总结一下,我不能将textbox的值传递给面板中的formbox,但是当它显示为msgbox时,它会显示值。

I already get it. 我已经明白了。 i should declare global and call the form inside the panel. 我应该声明全局并在面板内调用表单。

I am not sure what you mean by "Global" that seems to mean something different to different people. 我不确定你所说的“全球”是什么意思似乎意味着不同的人有所不同。

You could do it in one of two ways as far as I am concerned, you can either pass the values to constructor or create properties and get/set those properties. 就我而言,你可以用两种方法中的一种来做,你可以将值传递给构造函数或创建属性并获取/设置这些属性。

            Public Class Form1

                Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
                    Dim TxtFromTxtBoxOnForm2 As String = String.Empty
                    Dim Form2 As New Form2
                    With Form2
                        TxtFromTxtBoxOnForm2 = .ItmTxt
                        .TopLevel = False
                        .StartPosition = FormStartPosition.Manual
                        Panel1.Controls.Add(Form2)
                        .Show()
                    End With
                End Sub

            End Class

            Public Class Form2

                Public Property ItmTxt As String
                    Get
                        Return TextBoxOnForm2.Text
                    End Get
                    Set(value As String)
                        TextBoxOnForm2.Text = value
                    End Set
                End Property

            End Class

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM