首页  编辑  

RichTextBox显示光标停留的行列

Tags: /C#/界面处理/TextBox_RichEdit/   Date Created:

private void richTextBox1_SelectionChanged( object sender , EventArgs e)

{

    int X = (( RichTextBox )sender) . SelectionStart -

       (( RichTextBox )sender) . GetFirstCharIndexOfCurrentLine();

    int Y = (( RichTextBox )sender) . GetLineFromCharIndex(

       (( RichTextBox )sender) . SelectionStart);

   Text = string . Format( "Row:{0}, Col:{1}" , X, Y);

}