D
Dustin Davis
I've been having problems with databinding. I've created a simple
solution to emulate the problem I can't figure out. Basically, I have a
TextBox bound to a property in an object. When the property is updated,
how do I get the field to show the new value. I assumed that databinding
would take care of it automatically.
Here is my source code. Can someone tell me what I would need to do to
get TextBox2 to update after the f.value is changed? (The form as one
button (Button1) and two TextBox fiels (TextBox1 & TextBox2)
Public Class Form1
Private f As New Field
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' Set up binding
f.value = "test"
Me.TextBox2.DataBindings.Add("Text", f, "value", False,
DataSourceUpdateMode.OnPropertyChanged)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
f.value = Me.TextBox1.Text
End Sub
End Class
Public Class Field
Private sValue As String
Public Property value() As String
Get
Return sValue
End Get
Set(ByVal val As String)
Me.sValue = val
End Set
End Property
End Class
Thanks,
Dustin
solution to emulate the problem I can't figure out. Basically, I have a
TextBox bound to a property in an object. When the property is updated,
how do I get the field to show the new value. I assumed that databinding
would take care of it automatically.
Here is my source code. Can someone tell me what I would need to do to
get TextBox2 to update after the f.value is changed? (The form as one
button (Button1) and two TextBox fiels (TextBox1 & TextBox2)
Public Class Form1
Private f As New Field
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' Set up binding
f.value = "test"
Me.TextBox2.DataBindings.Add("Text", f, "value", False,
DataSourceUpdateMode.OnPropertyChanged)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
f.value = Me.TextBox1.Text
End Sub
End Class
Public Class Field
Private sValue As String
Public Property value() As String
Get
Return sValue
End Get
Set(ByVal val As String)
Me.sValue = val
End Set
End Property
End Class
Thanks,
Dustin