PavelTorgashov / FastColoredTextBox

Fast Colored TextBox for Syntax Highlighting. The text editor component for .NET.
Other
1.23k stars 465 forks source link

Getting the current line #225

Closed boduzapho closed 3 years ago

boduzapho commented 3 years ago

I am trying to, on mouse click, get the text of the currently selected line. Is there a method I missed? Also where can I change the color used for selected characters when a line is clicked?

Thanks in Advance

boduzapho commented 3 years ago

So I figured it out sort of.. On the click event, I query fctb.Selection.Start this gives me a list of the current column and row. So I set the fctb.Selection.Start to 0 on the same row, and extend the selection to the end of the row. Easier than I thought.

Code: private void FCTB_Click(object sender, EventArgs e) { String[] st = FCTB.Selection.Start.ToString().Replace("(","").Replace(")","").Split(','); textBox1.Text = FCTB.GetLine(Int32.Parse(st[1].ToString())).Text.ToString().Trim();
}