how do i get the text of the line in wich the Caret is on in a richtextbox?
I found this is how to get the index of the first chr but i am stuck there on.. RichTextBox1.GetFirstCharIndexOfCurrentLine
Printable View
how do i get the text of the line in wich the Caret is on in a richtextbox?
I found this is how to get the index of the first chr but i am stuck there on.. RichTextBox1.GetFirstCharIndexOfCurrentLine
vb.net Code:
MessageBox.Show(myRTB.Lines(myRTB.GetLineFromCharIndex(myRTB.SelectionStart))))
O i see it has a built in lines option. I was looking for somthing like line.
Thanks
Just note that you want to avoid using the Lines property repeatedly if you can. Each time you access the Lines property it returns a new string array, so if you intend to use it more than once in quick succession you should only access the property once and assign its value to a local variable. You then use that variable repeatedly and thus only one string array is created. You only need to access the property value again if there's a chance that the Text has changed in between.