Using: Windows 10, C# on Visual Studio 2017, WinForms.
I am attempting to format each line of a RichTextBox seperately, but have had some issues. Here is my current code method to create a "bold" a line:
-
- messageCounter++;
- DateTime dt = DateTime.Now;
- string time = dt.ToString("hh:mm tt");
- string message = "A BOLD message.";
- string statusText = "Message #" + messageCounter + "\t" + time + "\t\t" + message + "\n";
- StatusRichTextBox.Text = StatusRichTextBox.Text.Insert(0, statusText);
- StatusRichTextBox.Find(statusText);
- StatusRichTextBox.SelectionFont = new System.Drawing.Font(StatusRichTextBox.Font, System.Drawing.FontStyle.Bold);
-
-
- string howBig = StatusRichTextBox.SelectionLength.ToString();
- StatusRichTextBox.Text = StatusRichTextBox.Text.Insert(0, howBig);
My problem is that the Find will find the message variable, but not the time one or the statusText. And even when it finds the message variable, it won't make it bold, however I was able to make it bold in the past, but I forgot what I changed to do it.
If anyone could help me figure out why find isn't working for the two strings, that would be great. In addition, any hints on how to get the bold to work or even how to change the color of the selected text would be most appreciated.
Thank you.