Results 1 to 8 of 8

Thread: RichTextBox and background colour

  1. #1

    Thread Starter
    Addicted Member J@ck's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    179

    RichTextBox and background colour

    Wotcha, folks.

    I've been searching for a way in which to change the colour on just a selected portion of a rich text box.

    We have a RTB that lists information that is then checked and coloured according to the information it finds. I.e any text with the words "problems" is highlighted in red, etc.

    As we've now run out of distinguishable colours, I'd like to change the selected background colour.

    There was one relatively similar question asked here earlier, but it never really went anywhere.

    Is it possible to change the background colour of a selected piece of text in a RichTextBox?

    Much ta.

    Jack.

  2. #2
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: RichTextBox and background colour

    VB Code:
    1. With Me.RichTextBox1
    2.     .Text = ""
    3.     .SelBold = True
    4.     .SelFontSize = 20
    5.     .SelText = "Dataare" & vbNewLine
    6.    
    7.     .SelFontSize = 8
    8.     .SelBold = False
    9.     .SelColor = RGB(200, 0, 0)
    10.     .SelText = "Name:- "
    11.    
    12.     .SelColor = vbBlack
    13.     .SelText = "shakti singh dulawat" & vbNewLine & vbNewLine & "Email:- "
    14.    
    15.     .SelColor = &HC00000
    16.     .SelText = "[email protected]"
    17. End With

    To change the formatting of existing text, select some text and then change the desired "SEL" properties.

    VB Code:
    1. With Me.RichTextBox1
    2.     .SelStart = 0
    3.     .SelLength = 7
    4.     .SelBold = False
    5.     .SelItalic = True
    6.     .SelColor = vbYellow
    7. End With

  3. #3

    Thread Starter
    Addicted Member J@ck's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    179

    Re: RichTextBox and background colour

    Thanks for the reply, but I did mean the background colour.

    I'm fine with the font colour / style itself.

    J.

  4. #4
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: RichTextBox and background colour

    VB Code:
    1. With Me.RichTextBox1
    2.     .SelStart = 0
    3.     .SelLength = 7
    4.     .SelBold = False
    5.     .SelItalic = True
    6.     .SelColor = vbYellow
    7. End With

  5. #5
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: RichTextBox and background colour

    To change the formatting of existing text, select some text and then change the desired "SEL" properties.


    VB Code:
    1. With Me.RichTextBox1
    2.     .SelStart = 0
    3.     .SelLength = 7
    4.     .SelBold = False
    5.     .SelItalic = True
    6.     .BackColor = vbRed
    7. End With

  6. #6
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: RichTextBox and background colour

    Shakti: he wanted to change the back color of selected text i.e. highlight selected text, but you are posting code to just change the text color, i.e. forecolor. Please read the post clearly and then post your solution.

    Jack: I doubt you can change the back color of selected text in RTB. May be experts can help you.
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  7. #7
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: RichTextBox and background colour

    ok sir

  8. #8

    Thread Starter
    Addicted Member J@ck's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    179

    Re: RichTextBox and background colour

    Aww nadgers!

    Okay. Thanks for the input, guys.

    jack.

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