22-07-19, 07:19 PM
(22-07-19, 06:34 PM)Basil Abdallah كتب :(22-07-19, 06:16 PM)bakriano30@yahoo.com كتب :(22-07-19, 05:58 PM)سعود كتب : موضوع سؤال زي موضوعنا والجواب تحت زي جوابي هذاالجواب من ايدك يحلي اخ سعود
PHP كود :
Sub findTextAndHighlight(ByVal searchtext As String, ByVal rtb As RichTextBox)
Dim textEnd As Integer = rtb.TextLength
Dim index As Integer = 0
Dim fnt As Font = New Font(rtb.Font, FontStyle.Bold)
Dim lastIndex As Integer = rtb.Text.LastIndexOf(searchtext)
While (index < lastIndex)
rtb.Find(searchtext, index, textEnd, RichTextBoxFinds.WholeWord)
rtb.SelectionFont = fnt
rtb.SelectionLength = searchtext.Length
rtb.SelectionColor = Color.Red
rtb.SelectionBackColor = Color.Cyan
index = rtb.Text.IndexOf(searchtext, index) + 1
End While
End Sub
'============USAGE============
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
'this method with search for text "boy" in RichTextBox2, change the textcolor to red and back color to cyan as indicated in the screenshot below
findTextAndHighlight("boy", RichTextBox2)
End Sub
(22-07-19, 05:58 PM)سعود كتب : موضوع سؤال زي موضوعنا والجواب تحت زي جوابي هذاكذالك الاخطاء تستمر من فضلك مثال بسيط اخ سعود انا اسف لتعبك
PHP كود :
Sub findTextAndHighlight(ByVal searchtext As String, ByVal rtb As RichTextBox)
Dim textEnd As Integer = rtb.TextLength
Dim index As Integer = 0
Dim fnt As Font = New Font(rtb.Font, FontStyle.Bold)
Dim lastIndex As Integer = rtb.Text.LastIndexOf(searchtext)
While (index < lastIndex)
rtb.Find(searchtext, index, textEnd, RichTextBoxFinds.WholeWord)
rtb.SelectionFont = fnt
rtb.SelectionLength = searchtext.Length
rtb.SelectionColor = Color.Red
rtb.SelectionBackColor = Color.Cyan
index = rtb.Text.IndexOf(searchtext, index) + 1
End While
End Sub
'============USAGE============
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
'this method with search for text "boy" in RichTextBox2, change the textcolor to red and back color to cyan as indicated in the screenshot below
findTextAndHighlight("boy", RichTextBox2)
End Sub
تفضل اخ كريم
PHP كود :
Dim txt As String
txt = RichTextBox1.Find(TextBox1.Text)
RichTextBox1.SelectionBackColor = Color.Red
بارك الله فيك هذا هو المطلوب

