CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2018
    Posts
    5

    Cool Inserting Text to the beginning of a RichTextBox maintaining colors

    I have the following code:

    Code:
    txtStatusLog.SelectionStart = 0
    txtStatusLog.SelectionLength = 0
    txtStatusLog.SelectedText = ("ERROR: " & MyUpdate & "(" & Now & ")" & vbCrLf)
    txtStatusLog.SelectionColor = Color.Red
    Only problem is that when a different color is selected, the color either never appears or changes the entire text box that color. Any ideas on how to correct this?

  2. #2
    Join Date
    Jan 2018
    Posts
    5

    Re: Inserting Text to the beginning of a RichTextBox maintaining colors

    Looks like it works if I change the order a bit:

    Code:
    txtStatusLog.SelectionStart = 0
    txtStatusLog.SelectionLength = 0
    txtStatusLog.SelectionColor = Color.Red
    txtStatusLog.SelectedText = ("ERROR: " & MyUpdate & "(" & Now & ")" & vbCrLf)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured