RE: Rich Text box masks Line Feed
- From: AMercer <AMercer@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 28 Feb 2008 11:54:13 -0800
I tried that, unfortunately GetLineFromCharIndex() returns the UI line, not
the string array line. So, as the text wraps down the page, the
GetLineFromCharIndex() increments even though there has been no CR.
I can calculate this using the Lines().Length property, but surely MS must
have provided a faster and better way to know which line a character is in!
I assume you can't set WordWrap to false - if you can, problem solved.
This is getting ugly, but you could have two rtbs, one with word wrap and
one without. Show the one with wordwrap, calculate from the one without word
wrap, and keep them in sync.
Alternatively, there is the windows api. Sorry, no warranties for what
follows.
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hWnd As IntPtr, _
ByVal wMsg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Integer) _
As Integer
Const WM_USER As Integer = &H400
Const EM_EXLINEFROMCHAR As Integer = WM_USER + 54
dim l,c as integer ' zero based line number and character number
c = some zero based character index
l = SendMessage(RichTextBox1.Handle, EM_EXLINEFROMCHAR, 0, c)
.
- References:
- Rich Text box masks Line Feed
- From: Justin Roberts
- Rich Text box masks Line Feed
- Prev by Date: Console application. Console.Clear = IOException
- Next by Date: WinForm as AppBar
- Previous by thread: Rich Text box masks Line Feed
- Next by thread: Re: Rich Text box masks Line Feed
- Index(es):
Relevant Pages
|