Results 1 to 5 of 5

Thread: Rich Textbox Question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382

    Rich Textbox Question

    Is it possible to place color tags in a string so the rich textbox will automatically display the correct color WITHOUT have to set the forecolor on the physical control?

    Basically something like..


    Dim s as String = "<RED>This would be red...<BLUE>This is Blue..."


    The only thing I could find that would resemble something like that is the RTF option but that is for parsing actual text files?

    Anyone know?

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382
    Hmm, well I don't have office installed on my machine (or own it for that matter).. Surely there is a way to do it without having to install something..

  4. #4
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    Try this from MSDN: SelectionColor Property - RichTextBox

    Here's a code snippet from the article:

    VB Code:
    1. Public Sub ChangeMySelectionColor()
    2.     Dim colorDialog1 As New ColorDialog()
    3.    
    4.     ' Set the initial color of the dialog to the current text color.
    5.     colorDialog1.Color = richTextBox1.SelectionColor
    6.    
    7.     ' Determine if the user clicked OK in the dialog and that the color has
    8.     ' changed.
    9.     If (colorDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK) _
    10.         And Not(colorDialog1.Color.Equals(richTextBox1.SelectionColor)) Then
    11.        
    12.         ' Change the selection color to the user specified color.
    13.         richTextBox1.SelectionColor = colorDialog1.Color
    14.     End If
    15. End Sub
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382
    Thanks RealisticGraphics but that's not what I'm looking for.

    I am coding a Telnet client that handles Ansi Ascii colors.. Basically the server determines the color of the text by the Codes it imbedes into the text before sending it to the telnet client.. I need to be able to build a method that strips out the embeded color codes and replace them with some type of color tag that a rich text box will automatically recognize and change the color.

    Example would be...

    Dim Str as String = Chr(27) & "[1;40;33m" & "This is bold with black backround and yellow forground"

    Now I run this through a function that would return the string with the correct tags that a richtextbox would recognize..

    Any thoughts?

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