UWP Windows 10.
How to get lines count of RichEditBox?
I want to bind lines count, current line and current row to labels in statusbar (like in notepad). How can I do this?
UWP Windows 10.
How to get lines count of RichEditBox?
I want to bind lines count, current line and current row to labels in statusbar (like in notepad). How can I do this?
Take a look at this extended class
public class TextBoxEx : TextBox
{
public TextBoxEx()
{ }
public void GoTo(int line, int column)
{
if (line < 1 || column < 1 || this.Lines.Length < line)
return;
this.SelectionStart = this.GetFirstCharIndexFromLine(line - 1) + column - 1;
this.SelectionLength = 0;
}
public int CurrentColumn
{
get { return this.SelectionStart - this.GetFirstCharIndexOfCurrentLine() + 1; }
}
public int CurrentLine
{
get { return this.GetLineFromCharIndex(this.SelectionStart) + 1; }
}
}
Or even better; you could just write it like this:
public int CurrentColumn
{
get { return textBox1.SelectionStart - textBox1.GetFirstCharIndexOfCurrentLine() + 1; }
}