views:

62

answers:

2

Say I clicked somewhere inside a RichTextBox control. How can I get the current line the caret is currently on?

Btw this is to retrieve the whole text string of that line.

+1  A: 

One way is to send it the EM_LINEFROMCHAR Message. I'm sure there are other ways.

+2  A: 

That's what RichTextBox.GetLineFromCharIndex() does. Pass the SelectionStart property value.

Hans Passant
Thanks nobugz..
Joan Venge