Results 1 to 4 of 4

Thread: bold,italic, and the rest

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    ok , you know how in MS Word, if you have certain text lets say bolded, if you go back and put the cursor within the the bolded text, the BOLD toolbar button becomes pressed to show that the text is bolded, how'd they do that??

  2. #2
    Guest
    A RichTextBox must be used.

    And use these:

    Code:
    Private Sub Command1_Click()
    'Bold
    If RichTextBox1.Text <> "" Then
    RichTextBox1.SelBold = Not RichTextBox1.SelBold
    End If
    End Sub
    
    Private Sub Command2_Click()
    'Italic
    If RichTextBox1.Text <> "" Then
    RichTextBox1.SelItalic = Not RichTextBox1.SelItalic
    End If
    End Sub
    
    Private Sub Command3_Click()
    'Underline
    If RichTextBox1.Text <> "" Then
    RichTextBox1.SelUnderline = Not RichTextBox1.SelUnderline
    End If
    End Sub
    
    Private Sub Command4_Click()
    'Strike thru
    If RichTextBox1.Text <> "" Then
    RichTextBox1.SelStrikeThru = Not RichTextBox1.SelStrikeThru
    End If
    End Sub

  3. #3

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    no, what i mean is, lets say this:
    I've got a richtextbox and i type a little text in there. OK, so now I want to make two or three characters of the text bold. I've got a toolbar button with the code::

    If (richtextbox1.sellength <> 0) then
    richtextbox1.selbold = true
    end if

    and the button style is tbrChecked, Ok, so then i go and type some more text, but the BOLD button is still pressed.
    So my question is how do I get the button to become unpressed and SelBold to be turned off when I type in more text, and when I put the I-bar cursor back where the text is bolded have SelBold turned back on and the button become pressed again

  4. #4
    Guest
    Try this:

    Code:
    If (richtextbox1.sellength <> 0) then 
    richtextbox1.selbold = Not RichTextBox1.SelBold
    tbrChecked.Checked = Not tbrChecked.Checked
    end if

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