Results 1 to 5 of 5

Thread: RichTextBox Help

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    39

    Cool

    hi guys,

    Okay,

    my program consist of a richtextbox, textbox, combo box and command button.

    In the combobox I have the system fonts.
    The richtextbox(rtfmain.text) is the main window
    The text box is where the user types something in and after pressing the command button it shows at rtfmain.text.

    When I choose a specific font from the combo box it will change to that style on the rtrmain and the regular textbox.

    PROBLEM:
    The text in rtfmain.text all changes to that font.
    I need it to be that only the recent text entered in changes with the font style. Not the previous text allready in the rtfmain.text.

    Code:
    rtfMain.SelStart = Len(rtfMain.Text) '// auto scroll
                      
    rtfMain.Font = cboFonts.Text
    any ideas.


    Thanks in advance

  2. #2
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    To change just the font of a selected area of text (or to set the font of the current insertion point), use
    Code:
    rtfMain.SelFontName = "Courier New"
    If you don't use the .Sel... properties, you'll change the entire RTB's settings at once as you already know.
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    39
    hmmmm, I tried using that code and all the previous lines in the richtextbox still changed to the font.
    ?????

    Anything else

  4. #4
    Guest
    Works fine for me. Add the following code to a Form with a RichTextBox and CommandButton.
    Code:
    Private Sub Command1_Click()
        RichTextBox1.SetFocus
        RichTextBox1.SelFontName = "Courier New"
    End Sub

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    39
    ehhhh,

    Still not working for me. Here is what keeps happening.

    ( This is an example of the rtfmain.text )

    Username: Yakyack I love vb-world.net
    Username2: Yes I agree Vb world is the best source of vb
    Username: Well good luck programming.

    ( Now both of the users are you using the font arial. When the user clicks the font they wish to use in the cbofonts, that works fine. The problem that i am experiencing is that when they click the font of their choice and enter it in, all the lines before it ( such as the 3 lines before you which are in all arial) will turn into that font as well. I am only looking for a line to be a different font and the rest of the richtextbox to stay as it was.
    Sorry if this is not to clear.

    ???? Anything Im doing wrong?

    Thanks again in advance

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