-----Original Message-----
Oops, I misunderstood your original message. The message you want is
EM_LINEINDEX. You can use it to get the character indexes of the beginning
of a specified line. Try something like:
[DllImport("user32.dll", EntryPoint="SendMessage", CharSet = CharSet.Auto)]
private static extern int SendMessageInt(IntPtr hWnd, UInt32 Msg, Int32
wParam, Int32 lParam);
private const int EM_LINEINDEX= 0xBB;
public static int GetCharFromLineNumber(TextBoxBase control, int lineNumber)
{
return SendMessageInt(control.Handle, EM_LINEINDEX, lineNumber, 0);
}
Tom Clement
Apptero, Inc.
P.S. Also the code in my earlier post about EM_LINEFROMCHAR didn't pass in
the character position, so that would have to be fixed.
Tom Clement said:
I think you're looking for the EM_LINEFROMCHAR message. You need to do
something like the following (I haven't tested it).
[DllImport("user32.dll", EntryPoint="SendMessage",
CharSet =
CharSet.Auto)]
private static extern int SendMessageInt(IntPtr hWnd, UInt32 Msg, Int32
wParam, Int32 lParam);
private const int EM_LINEFROMCHAR = 0xC9;
public static int GetLineNumberFromChar(TextBoxBase control)
{
return SendMessageInt(control.Handle, EM_LINEFROMCHAR, -1, 0) + 1;
}
The docs say:
The EM_LINEFROMCHAR message retrieves the index of the line that contains
the specified character index in a multiline edit
control. A character
index
is the zero-based index of the character from the beginning of the edit
control. You can send this message to either an edit
control or a rich
edit
control.
Tom Clement
Apptero, Inc.
Is there a way to go to and select a particular line
number in a text box or rich text box?
I already know the line number that I need to go to.
Thanks in advance for any help you can provide.
.