Z
ZorpiedoMan
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!
-----------------------------------------------------------
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!