Zorpy,
In addition to the other comments, You need to define an Event as
EventHandler that has the same name as the Property with Changed on the end.
For example your Text property would need a TextChanged event, a Count
Property would need a CountChanged event.
This is explained in the following article
http://msdn.microsoft.com/library/de...et02252003.asp
Here is an example binding to multiple properties, with notifications:
Public Class Person
Public Event Text1Changed As EventHandler
Public Event Text2Changed As EventHandler
Private m_text1 As String
Private m_text2 As String
Public Sub New()
m_text1 = String.Empty
m_text2 = String.Empty
End Sub
Public Property Text1() As String
Get
Return m_text1
End Get
Set(ByVal value As String)
m_text1 = value
OnText1Changed(EventArgs.Empty)
End Set
End Property
Public Property Text2() As String
Get
Return m_text2
End Get
Set(ByVal value As String)
m_text2 = value
OnText2Changed(EventArgs.Empty)
End Set
End Property
Protected Overridable Sub OnText1Changed(ByVal e As EventArgs)
RaiseEvent Text1Changed(Me, e)
End Sub
Protected Overridable Sub OnText2Changed(ByVal e As EventArgs)
RaiseEvent Text2Changed(Me, e)
End Sub
End Class
Public Class PersonForm
Inherits System.Windows.Forms.Form
' ... designer generated code
Private aPerson As New Person
Private Sub Person_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.TextBox1.DataBindings.Add("Text", aPerson, "Text1")
Me.TextBox2.DataBindings.Add("Text", aPerson, "Text2")
End Sub
End Class
Hope this helps
Jay
"ZorpiedoMan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Why Doesn't THIS work:
> -----------------------------------------------------------
> A Windows Form has three controls:
> TextBox1
> BindButton
> ShowTextButton
> ChangeTextButton
>
> Code:
>
> Public Class SimpleClass
>
> Private myText as String
>
> Public Sub New(NewText as String)
> myText = NewText
> End Sub
>
> Public Property Text() As String
> Get
> Return myText
> End Get
> Set(Value as String)
> myText = Value
> End Set
> End Property
>
> End Class
>
> Private mySimpleClass as new SimpleClass("Hello")
>
> Private Sub BindButtonClick(...)...
> TextBox1.DataBindings.Add("Text", mySimpleClass, "Text")
> End Sub
>
> Private Sub ShowTextButtonClick(...)...
> MsgBox(mySimpleClass.Text)
> End Sub
>
> Private Sub changeTextButtonClick(...)...
> mySimpleClass.Textx = "Goodbye"
> End Sub
> -----------------------------------------------------------
>
> Ok... Here's what happens...
>
> 1. Run the program. No problem
> 2. Click The ShowText Button. "Hello" is shown. Fine.
> 3. Click the BindButton. TextBox1 shows "Hello". Still Fine.
> 4. Type "World" into TextBox1.
> 5. Click the ShowText Button. "World" is shown. So Far So Good...
> 6. Click the ChangeText Button. PROBLEM: TextBox1 still shows
> "World". NOT Good.
> 7. Click the ShowText Button. "GoodBye" is shown. As Expected.
>
> Why this one-way behavior? How do I get my SimpleClass to notify the
> Textbox it needs to change?
>
>
> --Zorpy
>
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!