.NET Idiosyncrasies #3: System.Windows.Forms.RichTextBox.SelectionFont
When selecting the very end of text contained in a RichTextBox, the selection appears to include an EOF character. This, in turn, will set the SelectionFont property to null.
When I encountered this problem, I assigned the value of the SelectionLength property to itself on a hunch, and it worked perfectly. To implement this, create your own class, derived from RichTextBox, and add the following code:
protected override void OnSelectionChanged(EventArgs e)
{
if (SelectionFont == null)
SelectionLength = SelectionLength; // Remove EOF from selection.
base.OnSelectionChanged(e);
}
[ Post Comment | Read Comments (0) ]
You can syndicate our content with this handy RSS feed.
Content © 2010 Torben K. Jensen. All rights reserved.
This website was made possible by Poseidon.
Content © 2010 Torben K. Jensen. All rights reserved.
This website was made possible by Poseidon.
