Put a RTB line number in Textbox .... then on BTN click event change text color of that line

Posted on 2010-03-26
Medium Priority
Last Modified: 2012-05-09
I want to enter a number in TextBox
   Number is a Line in RTB ie; Line 3 of RTB
Then on BTN click Selection color for that line changes to Red
Question by:vbMarkO
LVL 48

Accepted Solution

Wayne Taylor (webtubbs) earned 2000 total points
ID: 28724628
Try this code...

        Dim SelectedText As String = RichTextBox1.SelectedText
        RichTextBox1.SelectionColor = Color.Black
        Dim line As String = RichTextBox1.Lines(Convert.ToInt32(TextBox1.Text) - 1)
        RichTextBox1.Select(RichTextBox1.Find(line), line.Length)
        RichTextBox1.SelectionColor = Color.Red
        If SelectedText <> "" Then
            RichTextBox1.Select(RichTextBox1.Find(SelectedText), SelectedText.Length)
        End If

LVL 83

Expert Comment

ID: 28810139
Try function in the link to select the line and then just add

RichTextBox1.SelectionColor = Color.Red

after selection


Author Closing Comment

ID: 34026455
Right on the Money

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question