如何在richTextBox中获取当前行? [英] How to get the current line inside a richTextBox?

查看:359
本文介绍了如何在richTextBox中获取当前行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我需要一些帮助.
我有一个richTextbox,我想做的是显示在表单中用户所在行和列的某处.然后考虑到richTextBox类似于A4页面的事实,使用行值和字体大小等,我想以某种方式向用户发送他所在的页面的信号.
所以?请帮忙吗?

Hey guys, I need some help.
I have a richTextbox and what I want to do is display somewhere inside my form the current line and column where the user is situated. Then considering the fact that the richTextBox is to be something like an A4 page, using the line value and font size and so on I want to somehow signal to the user the page he''s on.
So? Any help please?

推荐答案

查看 [ ^ ] CodeProject文章.
看来本文中的控件完全可以满足您的需求. :)
Check out this[^] CodeProject article.
It seems that the control from the article does exactly what you need. :)


这可能不是最好的方法,但是我玩过它,似乎很奏效.如果不是您要找的东西,至少应该让您入门.

This might not be the best way to do it, but I played with it and it seems to work. If it''s not quite what you were looking for it should at least get you started.

Dim intLineNumber As Integer =  RichTextBox1.GetLineFromCharIndex(RichTextBox1.SelectionStart) + 1
Dim intCharIndexOfLine As Integer = RichTextBox1.GetFirstCharIndexOfCurrentLine()
Dim intCharIndex As Integer = RichTextBox1.SelectionStart
Dim intCol As Integer = Math.Abs(intCharIndexOfLine - intCharIndex)


这篇关于如何在richTextBox中获取当前行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆