CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 1 of 1
  1. #1
    Join Date
    Jul 2001
    Sunny South Africa

    [VB6] How Do I Work With The RichTextBox?

    Q: How Do I Add A Rich TextBox To My Application?

    A: Click Project, Components, and Select Microsoft Rich TextBox from the list

    Q: How Do Align Text In A RichTextBox?

    A: The Following Will Align The Text In The Center. Left And Right Are Similar :

    Private Sub cmdCenter_Click()
        'Center Align
        rtfText.SelAlignment = rtfCenter
    End Sub
    Q: How Do I Format The Text, Bold, Italic Or Underline?

    A: The Next Segment Will Bold, Italicise, Underline Text :

    Private Sub cmdBold_Click()
        rtfText.SelBold = Not rtfText.SelBold
    End Sub
    Private Sub cmdItalic_Click()
        rtfText.SelItalic = Not rtfText.SelItalic
    End Sub
    Private Sub cmdUnderline_Click()
        rtfText.SelUnderline = Not rtfText.SelUnderline
    End Sub
    Q: How Do I Change The Text Colour?

    A: The Next Segment Shows How To Change A Color, With The Use Of The CommonDialog Component, Which Must Be Added By Clicking Project, Components, And Selecting It From The Available List.

    Private Sub cmdColor_Click()
        'CommonDialog To Show Colours
        CD.Flags = cdlCFBoth 'Show All Colours
        rtfText.SelColor = CD.Color 'Set Colour
    End Sub
    A Full Example Of The RTB In Working Is Attached
    Attached Files Attached Files
    Last edited by HanneSThEGreaT; May 12th, 2010 at 08:15 AM.

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