|
-
Mar 6th, 2012, 11:56 AM
#5
Thread Starter
Lively Member
Re: Richttextbox
 Originally Posted by 4x2y
You said
and this is what i gave you.
How can you specify the beginning and the end of the sentence?
Try to pass colors of each text you add, like this
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim colors(3) As Drawing.Color
colors(0) = Drawing.Color.Red
colors(1) = Drawing.Color.Blue
colors(2) = Drawing.Color.Green
colors(3) = Drawing.Color.Brown
' add more colors if you need
AddText("this is first line" & vbNewLine, colors)
colors(0) = Drawing.Color.CadetBlue
colors(1) = Drawing.Color.Coral
colors(2) = Drawing.Color.Gray
colors(3) = Drawing.Color.HotPink
' add more colors if you need
AddText("this is the second line with different colors", colors)
End Sub
Private Sub AddText(ByVal Text As String, ByVal Colors() As Drawing.Color)
Dim strWords() As String = Text.Split(" "c)
With txtChat
For j As Integer = 0 To strWords.Length - 1
.SelectionColor = colors(j Mod colors.Length)
.AppendText(strWords(j) & " ")
Next
End With
End Sub
Yes Im sorry for that but my english isnt very good.
Thank you for the code!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|