Skip to content

Richtext - How to Goto Line number?

Andrew

Asked Jul 30, 2007, 2:16 PM EDT3 answers
Share
LinkedInX

Does anyone have idea how I can move the cursor to a certain line number in the Richtext edit?

Something like, Go to line number: _____  and then clicking OK button jumps the cursor to that line?

Your help is much appreciated.

Thanks.

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Mike Gold
    0
    C#
    /// <summary>
    /// Go To a particular line
    /// </summary>
    /// <param name="i"></param>
    private void GotoLine(int i)
    {
      int index = richTextBox1.GetFirstCharIndexFromLine(i-1);
      richTextBox1.Select(index, 0);
    }
    0
  • 0
    Many thanks Mike, specially to prompt response. It works fantastic.

    I have been googling around most of a day just to find the solution, and even went to Win32 API, but could not find one working.

    In addtion, this is the first time I post question here and I am very happy to find a place where I there are helpful developers that shares knowledge and experience.

    Again, thank you Mike and CSharpcorner.
    0
  • Mike Gold
    0
    No problem Andrew,

    it's a pleasure to help out.

    Best,
    0