Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: rich text box problem


Message #1 by "Coral Johnson" <coral@j...> on Mon, 25 Jun 2001 17:12:49 +1000
Divide and conquer.....

    With RichTextBox1
       .Font.Bold = False
       .Text = "Heading 1"
       .SelStart = 0
       .SelLength = Len(.Text)
       .SelBold = True
       .Refresh
   End with    

  and so on and so on ....

   With RichTextBox1
       .Text = .Text & vbCrLf & "Line 1"
       .SelStart = intEnd + 1
       .SelLength = Len(.Text) - .SelStart
       .SelBold = False
   End with 


HTH



Coral Johnson wrote:
> 
> I'm hoping someone can enlighten me on the intricacies of the rich text box
> control.  I am loading heading lines and data lines from a database, and I
> want the heading lines to be bold.  So I select the heading line after I add
> it, then set selbold=true.  Then I add a data line, select it, and set
> selbold=false.  But what seems to be happening, is that each time I add a
> line, all the text in the RTB is being set to bold, undoing what I have just
> done.
> 
> Private Sub LoadText()
> Dim intEnd As Integer
> 
>    With RichTextBox1
>       .Font.Bold = False
>       .Text = "Heading 1"
>       .SelStart = 0
>       .SelLength = Len(.Text)
>       .SelBold = True
>       intEnd = Len(.Text)
>       .Text = .Text & vbCrLf & "Line 1"
>       .SelStart = intEnd + 1
>       .SelLength = Len(.Text) - .SelStart
>       .SelBold = False
>       intEnd = Len(.Text)
>       .Text = .Text & vbCrLf & "Line 2"
>       .SelStart = intEnd + 1
>       .SelLength = Len(.Text) - .SelStart
>       .SelBold = False
>       intEnd = Len(.Text)
>       .Text = .Text & vbCrLf & "Heading 2"
>       .SelStart = intEnd + 1
>       .SelLength = Len(.Text) - .SelStart
>       .SelBold = True
>       .Text = .Text & vbCrLf & "Line 1"
>       .SelStart = intEnd + 1
>       .SelLength = Len(.Text) - .SelStart
>       .SelBold = False
>       intEnd = Len(.Text)
>       .Text = .Text & vbCrLf & "Line 2"
>       .SelStart = intEnd + 1
>       .SelLength = Len(.Text) - .SelStart
>       .SelBold = False
>       intEnd = Len(.Text)
>       .SelLength = 0
>    End With
> 
> End Sub
>


  Return to Index