Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VB.NET将数据绑定添加到textbox控件_Vb.net_Data Binding - Fatal编程技术网

VB.NET将数据绑定添加到textbox控件

VB.NET将数据绑定添加到textbox控件,vb.net,data-binding,Vb.net,Data Binding,如何将数据绑定到运行时创建的文本框中 创建我的文本框控件的代码 Private Function ADD_TEXTBOX_CONTROL(ByVal ParentControl As Control, ByVal Name As String, ByVal Text As String,

如何将数据绑定到运行时创建的文本框中

创建我的文本框控件的代码

    Private Function ADD_TEXTBOX_CONTROL(ByVal ParentControl As Control,
                                     ByVal Name As String,
                                     ByVal Text As String,
                                     ByVal Width As Integer,
                                     ByVal Pos_X As Integer,
                                     ByVal Pos_Y As Integer,
                                     ByVal oNewControlTooltip As String) As TextBox

    Dim oTB As New TextBox

    oTB.Name = Name
    oTB.Text = Text
    oTB.Width = Width
    oTB.Location = New Drawing.Point(Pos_X, Pos_Y)

    ParentControl.Controls.Add(oTB)

    Return oTB

End Function
假设我想用在命名空间中创建的类属性绑定这个文本框。因此,如果我的文本框值发生变化,Body_Cilinder.Height也会随之调整

Namespace BODY_NAMESPACE

' Class that defines all the Cilinders properties for easy access.
Class Body_Cilinder

    ' Counter to determinate the cilinder quantity required.
    Public Shared Count As Integer = 0

    ' Property decalration fir cilinder properties
    Private _Index As Integer
    Private _Elevation As Double
    Private _Height As Double

    ' Cilinder Index number As Integer for finding the position.
    Public Property Index() As Integer
        Get
            Index = _Index
        End Get
        Set(ByVal value As Integer)
            _Index = value
        End Set
    End Property

    ' Cilinder Elevation to define the cilinder elevation from the T.L.
    Public Property Elevation() As Double
        Get
            Elevation = _Elevation
        End Get
        Set(value As Double)
            _Elevation = value
        End Set
    End Property

    ' Cilinder Height to define the cilinder height.
    Public Property Height() As Double
        Get
            Height = _Height
        End Get
        Set(value As Double)
            _Height = value
        End Set
    End Property

    ' Add Cilinder count every-time a new "Body Cilinder" instance Is created
    Public Sub New()
        Count = Count + 1
    End Sub

End Class
结束命名空间

我需要补充什么? 我找到了这个例子,但我不太明白它是如何工作的

textBox1.DataBindings.Add _
   (New Binding("Text", ds, "customers.custName"))

这是一个映射操作。Text从数据集中“customers”数据表中的“custName”字段获取数据<代码>ds。同样,对文本框“流”的更改也会以相同的方式返回到数据库。我不确定它是否适用于你的代码你知道更好的方法吗?或者不可能这样吗?
textBox1.DataBindings.Add(新绑定(“Text”,cylinderObject,“Height”))
您必须为每个实例重建/重置。或者,您可以使用Enter和Leave事件来更新对象(更简单),您建议如何更新对象?我该怎么写?这是一个简单的命令,还是我需要让发送方使用它的绑定对象来执行此操作?