Private Sub SetLocalDataBindings()
If (Me.m_arg.ViewMode <EventArgs.ViewMode.AddNew) Then
Dim titleIdBinding As Binding = _
txtTitleId.DataBindings.Add("Text", Me.m_model, "TitleId")
'Improved in .NET 2.0 //
http://msdn2.microsoft.com/library/y...us,vs.80).aspx
'titleIdBinding.NullValue = "Type a TitleID Here"
AddHandler titleIdBinding.Format, AddressOf BindingNullCheck
''AddHandler titleIdBinding.Parse, AddressOf BindingNullCheck
'''Me.txtTitleId.DataBindings.Add(New Binding("Text",
Me.m_model, "TitleId"))
Me.txtPubId.DataBindings.Add(New Binding("Text", Me.m_model,
"CurrentPublisher.PublisherId"))
Me.txtTitle.DataBindings.Add(New Binding("Text", Me.m_model,
"Title"))
Me.txtPublisher.DataBindings.Add(New Binding("Text", Me.m_model,
"CurrentPublisher.PublisherName"))
Me.txtType.DataBindings.Add(New Binding("Text", Me.m_model,
"TitleType"))
Me.dtpPubDate.DataBindings.Add(New Binding("Value", Me.m_model,
"PublishedDate"))
Me.txtPubDate.DataBindings.Add(New Binding("Text", Me.m_model,
"PublishedDate"))
End If
If Not (Me.m_model.AllPublishers Is Nothing) Then
Me.cboPublisher.DataSource = Me.m_model.AllPublishers
Me.cboPublisher.DataBindings.Add(New Binding("SelectedItem",
Me.m_model, "CurrentPublisher"))
End If
End Sub
"Dustin Davis" <du****@davisvillage.comwrote in message
news:%2******************@TK2MSFTNGP05.phx.gbl...
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