Results 1 to 6 of 6

Thread: Change Text Color and Font Character by Character

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Location
    San Jose
    Posts
    70

    Change Text Color and Font Character by Character

    Hi,

    Is there a way to change a single line of text, making half, one color and the other half a different color in bold?

    Number of files (150) (150)

  2. #2
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Not in a text box. But in a Rich Text Box you can.
    Im not sure how, but im sure someone will get the
    code for ya =)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Location
    San Jose
    Posts
    70

    For Treeview

    I am trying to make my treeview act like Outlook, Displaying items not read in bold surrounded by brackets.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    I'm sure you can take this code, and expand it to meet your needs. This little snippet simply changes the color of one word, but the principle for what you wish to do remains the same.
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim strWord As String
    3. Dim lPos As Long
    4.  
    5. strWord = "Hello"
    6.  
    7. lPos = InStr(1, RichTextBox1.Text, strWord, vbTextCompare)
    8.  
    9. If lPos > 0 Then
    10.     With RichTextBox1
    11.        .SelStart = lPos - 1
    12.        .SelLength = Len(strWord)
    13.        .SelColor = vbRed
    14.        .SelStart = Len(RichTextBox1.Text)
    15.     End With
    16. End If

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Sorry. I submitted the post before I saw your second post specifiying a TreeView control.

  6. #6
    Addicted Member
    Join Date
    Sep 2000
    Posts
    230
    I dont think you can do this with the treeview control. I posted the same question a while ago, and nobody had any ideas. The only thing you can do in the treeview is format the entire node text with simple things like bold and underline.
    Shawn Hull
    VB6, SP3 (Professional Edition)

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