Trying to bind a String to a RichTextBox.Text property so that when the String value changes, that change is reflected in the RichTextBox. So far I’m unsuccessful.
string test = "Test";
rtxt_chatLog.DataBindings.Add("Text",test,null);
test = "a";
This shows “Test” in the rtxt_chatLog, but not the “a”.
Even tried adding rtxt_chatLog.Refresh(); but that does not make any difference.
Update 1:
This does not work either:
public class Test
{
public string Property { get; set; }
}
Test t = new Test();
t.Property = "test";
rtxt_chatLog.DataBindings.Add("Text", t, "Property");
t.Property = "a";
Am I not understanding data binding correctly?
The
Stringclass doesn’t implementINotifyPropertyChanged, so there are no events for the binding source to tell the RichTextBox that something changed.Try updating your class with the
INotifyPropertyChangedimplemented:}
Also, it looks like
DataBindingdoesn’t like the name “Property” for a property name. Try changing it to something else other than “Property”.