In my project, I want to use a richtextbox which is featured justified text align and render HTML tags. I examined and tried all examples in the web. But I did not find like in my mind. I tired AdvRichTextBox but it is not support HTML. I want to write some new feature to it. I tried to write a method like below:
private void htmlRTB(AdvRichTextBox rtb)
{
foreach (var line in rtb.Lines)
{
int boldStart = rtb.Find("<b>");
int boldEnd = rtb.Find("</b>");
rtb.Select(boldStart, (boldEnd - boldStart));
rtb.SelectionFont = new Font("Arial", 9, FontStyle.Bold);
line.Replace("<b>", "").Replace("</b>", "");
int italicStart = rtb.Find("<i>");
int italicEnd = rtb.Find("</i>");
rtb.Select(italicStart, (italicEnd - italicStart));
rtb.SelectionFont = new Font("Arial", 9, FontStyle.Italic);
line.Replace("<i>", "").Replace("</i>", "");
}
}
But it was screwed up. When the HTML tags were used in first time, they are shown bold or italic. But replace method do not work. And when the HTML tags were used in second or more time they are not shown bold or italic and replace method do not work. This is the screenshot image:
Please could you help me how do i solve this problem? Kind regards.