Very good, thanks!! Just one comment --- at end of while loop, the assignment of startIndex should be '=', not '+='. Took me a little while to find out why all instances of my searched word were not being found.
No, I think you can copy table, then paste to richtextbox. first you need to copy table then add to resource, see video how to add equation to richtextbox, i think similar the way. thanks
hey nice work keep it up .. but in my case i have my own searching method .. now i wanted to highlight the searched words .. can you help me out .. ???
Well.. I know this is an old Video but that code has an error and it will not work as intended. at the end of the while loop, the startIndex variable increments with the last found word index value plus its length, with the intention of continuing the search from the last match. The problem is that incrementing the value will skip many hits. The value should be incremented but changed: It should be "startIndex = wordStartIndex + word.Length;" cheers
Hi! I was wondering: How would I accomplish this from a different form? Say, if I were to press Ctrl+F, then Form2 should come up, with the find, find next, etc. I have the code (It works!) except that if I enter the richtextbox after find a word, the text is all blue. Here is my source: public static void Find(RichTextBox rtb, String word, Color color) { rtb.SelectionStart = 0; rtb.SelectionLength = rtb.TextLength; rtb.SelectionColor = Color.Black; if (word == "") { return; } int s_start = rtb.SelectionStart, startIndex = 0, index; while ((index = rtb.Text.IndexOf(word, startIndex)) != -1) { rtb.Select(index, word.Length); rtb.SelectionColor = color; startIndex = index + word.Length; } } private void button1_Click(object sender, EventArgs e) { Find(richtext, textBox1.Text, Color.Blue); } That is in Form2.cs I already know how to connect Form1 to Form2, I just need help fixing the selectioncolor after they find some text.
I Watch and Downloaded all Your Videos... Very Very excellent & helpful for me > Thanks
Very good, thanks!! Just one comment --- at end of while loop, the assignment of startIndex should be '=', not '+='. Took me a little while to find out why all instances of my searched word were not being found.
thank you, I also encountered such a problem and thanks to you it was solved❤❤
Thank you sooo much!! This helped my immensely!!!
thank u....do u know a method ,class or library to insert a dynamic sizable table to richtextbox c#?
No, I think you can copy table, then paste to richtextbox. first you need to copy table then add to resource, see video how to add equation to richtextbox, i think similar the way. thanks
Great videos dude, keep it up :)
Thank you so much :)
hello...thanku its amazing....kindly help me that who we (count) these highlighted words .....
OK. Thank you
hey nice work keep it up .. but in my case i have my own searching method .. now i wanted to highlight the searched words .. can you help me out .. ???
Ok. Let's me research. thanks
public static void Find(RichTextBox rtb, String word, Color color)
{
rtb.SelectionStart = 0;
rtb.SelectionLength = rtb.TextLength;
rtb.SelectionColor = Color.Black;
if (word == "")
{
return;
}
int s_start = rtb.SelectionStart, startIndex = 0, index;
while ((index = rtb.Text.IndexOf(word, startIndex)) != -1)
{
rtb.Select(index, word.Length);
rtb.SelectionColor = color;
startIndex = index + word.Length;
}
}
private void button1_Click(object sender, EventArgs e)
{
Find(richtext, textBox1.Text, Color.Blue);
}
That highlights it :)
Well.. I know this is an old Video but that code has an error and it will not work as intended. at the end of the while loop, the startIndex variable increments with the last found word index value plus its length, with the intention of continuing the search from the last match. The problem is that incrementing the value will skip many hits. The value should be incremented but changed: It should be "startIndex = wordStartIndex + word.Length;"
cheers
Thank you for your suggestion. Let me check again
nice
i have surce code have some error
cam i connact for u to help me ?
Yes, You can contact me via email. You can find my email in the about tab. Thanks
yess.. my problem solved, after watch this video
That's great. Thank you so much ^_^
Hi! I was wondering: How would I accomplish this from a different form? Say, if I were to press Ctrl+F, then Form2 should come up, with the find, find next, etc.
I have the code (It works!) except that if I enter the richtextbox after find a word, the text is all blue. Here is my source:
public static void Find(RichTextBox rtb, String word, Color color)
{
rtb.SelectionStart = 0;
rtb.SelectionLength = rtb.TextLength;
rtb.SelectionColor = Color.Black;
if (word == "")
{
return;
}
int s_start = rtb.SelectionStart, startIndex = 0, index;
while ((index = rtb.Text.IndexOf(word, startIndex)) != -1)
{
rtb.Select(index, word.Length);
rtb.SelectionColor = color;
startIndex = index + word.Length;
}
}
private void button1_Click(object sender, EventArgs e)
{
Find(richtext, textBox1.Text, Color.Blue);
}
That is in Form2.cs I already know how to connect Form1 to Form2, I just need help fixing the selectioncolor after they find some text.
OK. Thank you for your suggestion. I'll update soon
Sorry but 3:14 I can't find the Find method is word!!
the program is wrong. startindex += must be startindex =
Isn't there an easier way to do this, without any indexof and shit, cause it is pretty complicated for only the back color
nice
i have surce code have some error
cam i connact for u to help me ?
Hi, What error are you getting ? Thanks