【问题标题】:Why i can't pass data from form textbox to form textbox inside panel VB.NET为什么我不能将数据从表单文本框传递到面板 VB.NET 内的表单文本框
【发布时间】:2019-06-04 02:26:59
【问题描述】:

这是调用表单并显示在面板中的代码

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

这是从表单传递数据并显示在面板内部的表单内的代码

 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**

总结一下,我不能将文本框的值传递给面板内的文本框,但是当它显示为 msgbox 时,它会显示该值。

【问题讨论】:

    标签: vb.net


    【解决方案1】:

    我不确定您所说的“全球”是什么意思,它似乎对不同的人有不同的含义。

    就我而言,您可以通过以下两种方式之一进行操作,您可以将值传递给构造函数或创建属性并获取/设置这些属性。

                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
    

    【讨论】:

    • 顺便说一句,谢谢你的回答,它有帮助!欢呼。
    • 我的意思是我在模块中声明这个并将dim更改为public。 (公共 frmLubesInterface As LubesInterface = New LubesInterface)现在我将通过 frmlubesinterface.textbox.text 调用它
    【解决方案2】:

    我已经明白了。我应该声明全局并调用面板内的表单。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-26
      • 1970-01-01
      相关资源
      最近更新 更多