如何在运行时创建的文本框中创建数据绑定?
创建我的文本框控件的代码
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"))