0
I have a simple application that only reads a file and returns what is in it within a richtextbox. The Point is when I click on the inside of the richtextbox, I would have to turn to the position of the row and column where it was clicked, equal to the functionality of a normal Notepad as shown in the figure.
I managed to catch the line and position through the mousedown function.
Is there any ready-made method to return the spine ? I searched the microsoft documentation but did not find.
code I’ve done so far
private void rtbVisualizar_MouseDown(object sender, MouseEventArgs e)
{
int pos = rtbVisualizar.SelectionStart;
int linha = rtbVisualizar.GetLineFromCharIndex(pos);
lblLC.Text = $"Linha: {linha + 1} | Coluna: | Posição: {pos + 1}";
}
Please clarify your problem or provide additional details in order to highlight exactly what you need. The way it’s written these days it’s hard to tell exactly what you’re asking.
–
Tried the
CaretPosition
? https://docs.microsoft.com/pt-br/dotnet/api/system.windows.controls.richtextbox.caretposition?view=net-5.0– Leandro Angelo