I am trying to make a simple WYSIWYG editor. I found pretty difficult to format the rtb. It is supposed to format basic things like bold, italic, coloring(and mixed).
What have I found and tried so far:
private void boldButton_Click(object sender, EventArgs e)
{
int start = rtb.SelectionStart;
int length = rtb.SelectionLength;
for (int i = start, max = start + length; i < max; ++i)
{
rtb.Select(i, 1);
rtb.SelectionFont = new Font(rtb.Font, rtb.SelectionFont.Style | FontStyle.Bold);
}
rtb.SelectionStart = start;
rtb.SelectionLength = length;
rtb.Focus();
}
rtb = richtextbox.
This works as expected, but is terribly slow. I also found the idea about using and formatting directly the RTF, but the format seems too complicated and very easy to mistake it. I hope it is a better solution.
Thank you.