引用 acmilan:
可能.NET的Text属性的实现有问题,建议尝试一下不改变Text属性,而是直接调用SetWindowText或者发送WM_SETTEXT设置文本。
TextBox继承自ConTrol
<code class="lang-c">// System.Windows.Forms.TextBox
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
this.selectionSet = false;
}
}</code>
ConTrol的
<code class="lang-c">// System.Windows.Forms.Control
[Bindable(true), Localizable(true), DispId(-517), SRCategory("CatAppearance"), SRDescription("ControlTextDescr")]
public virtual string Text
{
get
{
if (!this.CacheTextInternal)
{
return this.WindowText;
}
if (this.text != null)
{
return this.text;
}
return "";
}
set
{
if (value == null)
{
value = "";
}
if (value == this.Text)
{
return;
}
if (this.CacheTextInternal)
{
this.text = value;
}
this.WindowText = value;
this.OnTextChanged(EventArgs.Empty);
if (this.IsMnemonicsListenerAxSourced)
{
for (Control control = this; control != null; control = control.ParentInternal)
{
Control.ActiveXImpl activeXImpl = (Control.ActiveXImpl)control.Properties.GetObject(Control.PropActiveXImpl);
if (activeXImpl != null)
{
activeXImpl.UpdateAccelTable();
return;
}
}
}
}
}</code>