المشاركات : 164
المواضيع 55
الإنتساب : Jul 2019
السمعة :
3
الشكر: 117
تم شكره 146 مرات في 94 مشاركات
ريتش بوكس 1
تيكست بوكس 1
بوتن1
الريتش بوكس فيه كلمه السلام عليكم
محتاج اعمل بحث عن اي كلمه في الريتش بوكس من خلال التكست بوكس يعني لو كتبت السلام في التكست بوكس
عند الضغط علي بوتن 1 يتغير لو خلفيه التكست بوكس الي اخضر
المشاركات : 7,394
المواضيع 803
الإنتساب : Sep 2013
السمعة :
847
الشكر: 13249
تم شكره 18798 مرات في 4415 مشاركات
الشرح هنا وتمت التجربة بنجاح.
اللهم إني أعوذ بك من غلبة الدين وغلبة العدو، اللهم إني أعوذ بك من جهد البلاء ومن درك الشقاء ومن سوء القضاء ومن شماتة الأعداء، اللهم أصلح لي ديني الذي هو عصمة أمري، وأصلح لي دنياي التي فيها معاشي، وأصلح لي آخرتي التي فيها معادي، واجعل الحياة زيادة لي في كل خير، واجعل الموت راحة لي من كل شر
اللهم اغفر لي خطيئتي وجهلي، وإسرافي في أمري وما أنت أعلم به مني، اللهم اغفر لي جدي وهزلي وخطأي وعمدي وكل ذلك عندي، اللهم اغفر لي ما قدمت وما أخرت، وما أسررت وما أعلنت وما أنت أعلم به مني، أنت المقدم وأنت المؤخر وأنت على كل شيء قدير
المشاركات : 164
المواضيع 55
الإنتساب : Jul 2019
السمعة :
3
الشكر: 117
تم شكره 146 مرات في 94 مشاركات
22-07-19, 05:49 PM
(آخر تعديل لهذه المشاركة : 22-07-19, 05:49 PM {2} بواسطة bakriano30@yahoo.com.)
(22-07-19, 05:41 PM)سعود كتب : الشرح هنا وتمت التجربة بنجاح.
للاسف اطلعت عليه من قبل اخ سعود ولم افهم الكود اطلاقا حتي استعمله
(22-07-19, 05:41 PM)سعود كتب : الشرح هنا وتمت التجربة بنجاح.
للاسف اطلعت عليه من قبل اخ سعود ولم افهم الكود اطلاقا حتي استعمله
المشاركات : 7,394
المواضيع 803
الإنتساب : Sep 2013
السمعة :
847
الشكر: 13249
تم شكره 18798 مرات في 4415 مشاركات
موضوع سؤال زي موضوعنا والجواب تحت زي جوابي هذا
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
اللهم إني أعوذ بك من غلبة الدين وغلبة العدو، اللهم إني أعوذ بك من جهد البلاء ومن درك الشقاء ومن سوء القضاء ومن شماتة الأعداء، اللهم أصلح لي ديني الذي هو عصمة أمري، وأصلح لي دنياي التي فيها معاشي، وأصلح لي آخرتي التي فيها معادي، واجعل الحياة زيادة لي في كل خير، واجعل الموت راحة لي من كل شر
اللهم اغفر لي خطيئتي وجهلي، وإسرافي في أمري وما أنت أعلم به مني، اللهم اغفر لي جدي وهزلي وخطأي وعمدي وكل ذلك عندي، اللهم اغفر لي ما قدمت وما أخرت، وما أسررت وما أعلنت وما أنت أعلم به مني، أنت المقدم وأنت المؤخر وأنت على كل شيء قدير
المشاركات : 164
المواضيع 55
الإنتساب : Jul 2019
السمعة :
3
الشكر: 117
تم شكره 146 مرات في 94 مشاركات
22-07-19, 06:16 PM
(آخر تعديل لهذه المشاركة : 22-07-19, 06:19 PM {2} بواسطة 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
كذالك الاخطاء تستمر من فضلك مثال بسيط اخ سعود انا اسف لتعبك
المشاركات : 342
المواضيع 84
الإنتساب : Nov 2016
السمعة :
17
الشكر: 231
تم شكره 299 مرات في 178 مشاركات
(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
Basil Abdallah
المشاركات : 164
المواضيع 55
الإنتساب : Jul 2019
السمعة :
3
الشكر: 117
تم شكره 146 مرات في 94 مشاركات
(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
بارك الله فيك هذا هو المطلوب
المشاركات : 137
المواضيع 2
الإنتساب : Dec 2017
السمعة :
40
الشكر: 45
تم شكره 384 مرات في 134 مشاركات
بعد اذن جيمع الزملاء بارك الله فيهم ... اعتقد ان هذا الكود اسهم و اوضح ومختصر ايضا
كود :
For Each x As Match In Regex.Matches(RichTextBox1.Text, TextBox1.Text)
RichTextBox1.Select(x.Index, x.Length)
RichTextBox1.SelectionBackColor = Color.Yellow
Next
المشاركات : 7,394
المواضيع 803
الإنتساب : Sep 2013
السمعة :
847
الشكر: 13249
تم شكره 18798 مرات في 4415 مشاركات
بارك الله فيكم جميعا وشكر لكم.
كيف ممكن نعدل بحيث لو انقصنا من طول النص يتم الغاء ماكان مظلل بنتيجة البحث السابقة؟!
اللهم إني أعوذ بك من غلبة الدين وغلبة العدو، اللهم إني أعوذ بك من جهد البلاء ومن درك الشقاء ومن سوء القضاء ومن شماتة الأعداء، اللهم أصلح لي ديني الذي هو عصمة أمري، وأصلح لي دنياي التي فيها معاشي، وأصلح لي آخرتي التي فيها معادي، واجعل الحياة زيادة لي في كل خير، واجعل الموت راحة لي من كل شر
اللهم اغفر لي خطيئتي وجهلي، وإسرافي في أمري وما أنت أعلم به مني، اللهم اغفر لي جدي وهزلي وخطأي وعمدي وكل ذلك عندي، اللهم اغفر لي ما قدمت وما أخرت، وما أسررت وما أعلنت وما أنت أعلم به مني، أنت المقدم وأنت المؤخر وأنت على كل شيء قدير
المشاركات : 137
المواضيع 2
الإنتساب : Dec 2017
السمعة :
40
الشكر: 45
تم شكره 384 مرات في 134 مشاركات
بهذه الطريقة
كود :
RichTextBox1.SelectAll()
RichTextBox1.SelectionBackColor = Color.White
For Each x As Match In Regex.Matches(RichTextBox1.Text, TextBox1.Text)
RichTextBox1.Select(x.Index, x.Length)
RichTextBox1.SelectionBackColor = Color.Yellow
Next
|