RichTextBox: Podświetlanie konkretnej linii

Podświetlenie konkretnej linii richtextboxa

public static void HighlightLine(RichTextBox richTextBox, int index, Color color) // Funkcja ze stackoverflow
{
richTextBox.SelectAll();
richTextBox.SelectionBackColor = richTextBox.BackColor;
var lines = richTextBox.Lines;
if (index = lines.Length)
return;
var start = richTextBox.GetFirstCharIndexFromLine(index); // Get the 1st char index of the appended text
var length = lines[index].Length;
richTextBox.Select(start, length); // Select from there to the end
richTextBox.SelectionBackColor = color;
}

https://stackoverflow.com/questions/27217884/highlighting-a-line-of-text...

Tags: