transcend3nt
asked on
.NET Windows Form RichTextBox append text causes color inconsistency
This is a very unique problem I am facing.
In .NET 2.0, if you want to append formatted text (with font styles/color) into a rich textbox, you use this code :
richtextbox.SelectionFont = fontFromFontDialog;
richtextbox.SelectionColor = colorFromColorDialog;
richtextbox.AppendText("So me text");
the font and color are obtained from a color and font dialog.
For the first few times, the colors are correct. however if i keep changing font and colors, the colors get mixed up. If i select orange, it might appear blue on the richtextbox.
Anyone can give a solution? Really surprusing..
In .NET 2.0, if you want to append formatted text (with font styles/color) into a rich textbox, you use this code :
richtextbox.SelectionFont = fontFromFontDialog;
richtextbox.SelectionColor
richtextbox.AppendText("So
the font and color are obtained from a color and font dialog.
For the first few times, the colors are correct. however if i keep changing font and colors, the colors get mixed up. If i select orange, it might appear blue on the richtextbox.
Anyone can give a solution? Really surprusing..
richtextbox.SelectionFont = fontFromFontDialog;
richtextbox.SelectionColor = colorFromColorDialog;
richtextbox.AppendText("Some text");
// keep looping this with different colors/fonts will give wrong colors
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.