Results 1 to 4 of 4

Thread: HELP: Rich Text Boxes

  1. #1

    Thread Starter
    Fanatic Member Emcrank's Avatar
    Join Date
    Jan 2009
    Posts
    566

    HELP: Rich Text Boxes

    I have a number of questions about rich text box.

    1. How do i change the font by clicking a button.

    2. Also i want a Find control but how do i get it to find it then select it.

    3. Lastly Im having a Find and Replace where it finds the text in a textbox and then replaces it with what ever is in another textbox.

  2. #2
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: HELP: Rich Text Boxes

    For 3 use the replace command.

    Code:
    RichTextBox1.Text = RichTextBox1.Text("Text to Be Replaced", "Text to Replace with")
    And could you give an example for 2? It doesn't make much sense.
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  3. #3

    Thread Starter
    Fanatic Member Emcrank's Avatar
    Join Date
    Jan 2009
    Posts
    566

    Re: HELP: Rich Text Boxes

    That doesn't work and an example for number 2 is this:

    Ok lets say i have a peice of text:
    Code:
    Hi, Grandma lets go to the shop
    but i wanted to just find
    Code:
    Grandma lets go
    i want it to find this text then select it (highlight it)

    This is what doesn't work about it: i have this but it doesn't work
    Code:
    RTB1.Text = RTB1.Text(Find_TB.Text, Replace_TB.Text)

  4. #4
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: HELP: Rich Text Boxes

    Do you want to simply highlight Grandma lets go, or do you want for all the text except for Grandam lets go to be removed? If all you want to do is highlight it, use this:

    Code:
            Dim theText As String = "happy burger"
            RichTextBox1.Select(RichTextBox1.Text.IndexOf(theText), theText.Length)
            RichTextBox1.Focus()
    Also, could you be more descriptive about whats wrong with 3? The code I gave you works perfectly fine for me, is it not doing what you want, is it giving you an error, what's "wrong" with it?

    As for 1:

    Code:
            RichTextBox1.Font = New Font("Arial", RichTextBox1.Font.Size, RichTextBox1.Font.Style)
    To change the font you have to set the size and style, this will only change the font though as you can set it to remain the same.
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

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