问题
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