问题描述
为什么这不起作用:
------------------------------- ----------------------------
Windows窗体有三个控件:
TextBox1
BindButton
ShowTextButton
ChangeTextButton
代码:
Public Class SimpleClass
私有myText as String
Public Sub New(NewText as String)
myText = NewText
End Sub
Public Property Text()As String
Get
返回myText
结束获取
设置(值为字符串)
myText = Value
结束集
结束财产
结束班
私人mySimpleClass作为新的SimpleClass(你好)
Private Sub BindButtonClick(...)...
TextBox1.DataBindings.Add(" Text",mySimpleClass," Text")
End Sub
Private Sub ShowTextButtonClick(...)...
MsgBox(mySimpleClass.Text)
End Sub
Private Sub changeTextButtonClick(...)...
mySimpleClass.Textx =再见
结束子
--------------------------- --------------------------------
好的......这里'发生了什么......
1.运行程序。没问题
2.单击ShowText按钮。 "你好"显示。好的。
3.单击BindButton。 TextBox1显示Hello。还是很好。
4.输入世界字样。到TextBox1。
5.单击ShowText按钮。 "世界"显示。这么好......
6.单击ChangeText按钮。问题:TextBox1仍显示
World。不好。
7.单击ShowText按钮。 "再见"显示。正如预期的那样。
为什么这种单行为?如何让我的SimpleClass通知需要更改的
文本框?
--Zorpy
***已发送通过Devdex ***
不要只是参加USENET ......获得奖励!
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!
推荐答案
这篇关于另一个有约束力的问题......更简单......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!