Select the first line of a richtextbox when the test is there

Les 281 Reputation points
2020-12-30T20:47:01.073+00:00

I am having a problem selecting the first line of a richtextbox. I fill the rtb with text and all I want to do is when the text is loaded into the box I want the first line highlighted.

Can someone help me?

Thanks

Les

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,724 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 85,131 Reputation points
    2020-12-30T21:32:40.957+00:00

    You can do for example :

        Dim nStart As Integer = RichTextBox1.GetFirstCharIndexFromLine(0)
        Dim nLength As Integer = RichTextBox1.Lines(0).Length
        RichTextBox1.Select(nStart, nLength)
        RichTextBox1.Focus()
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.