Richtextbox Databinding issue on typing

五迷三道 提交于 2020-01-15 10:29:17

问题


After binding object to Richtextbox using bindingsource, if i type anything inside the textbox cursor will move to beginning. Can someone please help me.

I am binding as below

this.txtDescription.DataBindings.Add("Text", bindingWard, "Description", 
                         false, DataSourceUpdateMode.OnPropertyChanged);

回答1:


Try changing the DataSourceUpdateMode to OnValidation:

this.txtDescription.DataBindings.Add("Text", bindingWard, "Description", 
                     false, DataSourceUpdateMode.OnValidation);

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);



回答2:


Setting formattingEnabled=true solved the problem for me.




回答3:


try richTextBox1.ScrollToEnd(); after binding



来源:https://stackoverflow.com/questions/20243839/richtextbox-databinding-issue-on-typing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!