CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: RichText Box

  1. #1
    Join Date
    Dec 1998
    Posts
    1

    RichText Box



    How I can write in a RichTextBox using multiple font color?


    Thanks,

    AA.Keynia

  2. #2
    Join Date
    Dec 1998
    Posts
    28

    Re: RichText Box



    The SelColor property.

  3. #3
    Join Date
    Dec 1998
    Posts
    2

    Re: RichText Box



    Hi,

    If you want to change the color of the text in Rich Text Box, first select the text to be changed and use selcolor property. I have added a sample vb code.


    Place a richtextbox and change the name property to rt.

    Load a text file with word Start# and End#.

    The following code will change the contents in between Start# and End# to red color.


    Private Sub Form_Load()

    startpos = 0

    Do While Not flag

    rt.SelLength = 0

    startpos = rt.Find("START#", startpos)

    If startpos = -1 Then flag = True

    startpos = startpos + rt.SelLength

    rt.SelLength = 0

    endpos = rt.Find("END#", startpos)

    If endpos = -1 Then flag = True

    If Not flag Then

    rt.SelStart = startpos

    rt.SelLength = endpos - startpos

    rt.SelColor = vbRed

    End If

    startpos = endpos

    Loop

    End Sub



    I hope this code also will help you.


    Bye


    A. Karthikeyan



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