S
S
Sasha Pleshakov2016-07-20 15:10:25
C++ / C#
Sasha Pleshakov, 2016-07-20 15:10:25

Why is text not bold in RichTextBox?

public static void AddLineAndBlob(ref RichTextBox textBox, KeyValuePair<string, double[]> item, string[] blob)
{
    textBox.Text += item.Key + " ";
    int selectIndex = textBox.Text.Length;
    for (int i = 0; i < item.Value.Length; i++)
    {
        if (Array.IndexOf(blob, item.Value[i].ToString()) == -1)
        {
            textBox.Text += item.Value[i].ToString() + " ";
            selectIndex += textBox.Text.Length;
         }
         else
         {
              textBox.Text += item.Value[i].ToString() + " ";
              textBox.Select(selectIndex, item.Value[i].ToString().Length);
              textBox.SelectionFont = new Font(textBox.Font, FontStyle.Bold);
              selectIndex += textBox.Text.Length;
          }
    }
    textBox.Text += "\n";
}

Here is my method. All conditions pass correctly, no exceptions. But there is still no bold text. What is the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
#
#algooptimize #bottize, 2016-07-20
@mnepoh

after changing .Text you can forget about formatting
. I suggest checking this statement.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question