简体   繁体   English

行,WPF,RichTextBox中的列

[英]Line, column in RichTextBox, WPF

I am wondering how to update my status bar with line and column number automatically using the RichTextBox in WPF. 我想知道如何使用WPF中的RichTextBox自动用行号和列号更新状态栏。

First of all, which event do I hook on to? 首先,我要挂接到哪个事件? My box is multiline. 我的盒子是多行的。 KeyDown doesn't react to caret up and down movement. KeyDown不会对插入符号的上下移动做出反应。

The line number can be computer using: 行号可以是使用以下内容的计算机:

int someBigNumber = int.MaxValue;
int lineMoved, currentLineNumber;
editor.CaretPosition.GetLineStartPosition(-someBigNumber, out lineMoved);
currentLineNumber = -lineMoved + 1;
status_bar.Text = "Line " + currentLineNumber.ToString();

How do I get the column? 如何获得专栏?

I know this question is really old but I just solved it after having the issue myself. 我知道这个问题确实很老,但是我自己解决问题后才解决。

c# WPF Line and Column number from RichTextBox c#WPF RichTextBox中的行和列号

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM