C#笔记:richtextbox 用法 1 获取当前视图的第一行行号Point pos = new Point(10, 10); int firstIndex = this.richTextBox1.GetCharIndexFromPosition(pos); int firstLine = this.richTextBox1.GetLineFromCharIndex(firstIndex) + 1;2 跳转到指定行[DllImport("user32.dll", EntryPoint = "SendMessage")] public static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam); public const int EM_LINESCROLL = 0xb6; ..... SendMessage(this.richTextBox2.Handle,EM_LINESCROLL, 0, firstLine - 1); .....3 获取当前光标行号int index = richTextBox1.GetFirstCharIndexOfCurrentLine(); int line = richTextBox1.GetLineFromCharIndex(index) + 1;4 跳转到文章最开始richTextBox2.SelectionStart = 0; richTextBox2.ScrollToCaret(); 来自 大脸猫 写于 2016-07-16 21:08 -- 更新于2020-10-19 13:06 -- 1 条评论