Richtextbox打字时的数据绑定问题 [英] Richtextbox Databinding issue on typing
本文介绍了Richtextbox打字时的数据绑定问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用bindingsource将对象绑定到Richtextbox后,如果我在文本框内键入任何内容,游标将移动到开头。有人可以帮助我。
After binding object to Richtextbox using bindingsource, if i type anything inside the textbox cursor will move to beginning. Can someone please help me.
我的约束如下
this.txtDescription.DataBindings.Add("Text", bindingWard, "Description",
false, DataSourceUpdateMode.OnPropertyChanged);
推荐答案
尝试将DataSourceUpdateMode更改为OnValidation:
Try changing the DataSourceUpdateMode to OnValidation:
this.txtDescription.DataBindings.Add("Text", bindingWard, "Description",
false, DataSourceUpdateMode.OnValidation);
如果要保留OnPropertyChanged设置,可以尝试更改ControlUpdateMode,这是一种创建单向绑定的方法:
If you want to keep the OnPropertyChanged setting, you can try changing the ControlUpdateMode, which is sort of a way to create a one-way binding:
Binding b = new Binding("Text", test, "Description",
false, DataSourceUpdateMode.OnPropertyChanged);
b.ControlUpdateMode = ControlUpdateMode.Never;
this.txtDescription.DataBindings.Add(b);
这篇关于Richtextbox打字时的数据绑定问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文