Results 1 to 6 of 6

Thread: Fonts in RichTextBox

  1. #1

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544

    Post

    How can i change the font and fontsize in a RichTextBox???
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Use the SelFontName and SelFontSize Properties after selecting the Text you want to alter with the SelStart and SelLength Properties.

  3. #3
    Addicted Member
    Join Date
    May 1999
    Location
    Californ-I- A
    Posts
    207

    Post

    RichEdit1.selfontname = "Times New Roman"
    RichEdit1.selfontsize = 10

    If you want all the font of the entire box to be the same do

    'Highlight all text
    RichEdit1.SelStart = 1
    RichEdit1.selLength = len(RichEdit.Text)

    'Set font properties
    RichEdit1.SelFontName = "Times New Roman"
    RichEdit1.SelFontSize = 10

    'UnSelect all text
    RichEdit1.SelLength = 0
    Micah Carrick
    Visual Basic 6 SP5
    Visual Basic.NET
    Quixotix Software
    [email protected]
    Download QCM 1.0 - Intelligent ActiveX Control Management

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Check out SelFontName. Try this. Add a RichTextBox and a ListBox to your form:

    Code:
    Private Sub Form_Load()
        Dim i As Integer
        
        For i = 0 To Screen.FontCount - 1
            List1.AddItem Screen.Fonts(i)
        Next
    End Sub
    
    Private Sub List1_Click()
        RichTextBox1.SelFontName = List1.List(List1.ListIndex)
    End Sub
    Selecting the FontName in the ListBox will change the font in the RichTextBox.


  5. #5
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Wow, 3 replies in 4 min...

  6. #6

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544

    Post Thanks guys!

    Thanks for the quick replies!!! : o )))

    Edited by CyberCarsten on 03-08-2000 at 05:25 PM
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

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