| | |
End of Text in RichTextbox
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
Neither me..
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Jun 2009
Posts: 33
Reputation:
Solved Threads: 0
I have one richtext box in my windows application and wrote few lines in that richtext box say - 7 lines
Now I want to read all the text of richtext box word by word and want to search particular word in those text.
I know there is find() in C# but I don't want to use that.
I hope now I am clear to every body
Now I want to read all the text of richtext box word by word and want to search particular word in those text.
I know there is find() in C# but I don't want to use that.
I hope now I am clear to every body
To get word by word then search on specific word
C# Syntax (Toggle Plain Text)
int GetWordIndex(string word) { char[] splitters = new char[]{' '}; string[] wordsArr = RichTextBox1.Text.Split(splitters, StringSplitOptions.RemoveEmptyEntries); for(int i=0; i< wordsArr.Length; i++) if(string.Equals(wordsArr[i], word, StringComparison.InvariantCultureIgnoreCase)) return i; return -1; //indicates there is no match }
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
What do you want to use?
c# Syntax (Toggle Plain Text)
private void button1_Click(object sender, EventArgs e) { string find = "blu"; if (0 <= richTextBox1.Text.IndexOf(find, StringComparison.InvariantCultureIgnoreCase)) { System.Diagnostics.Debugger.Break(); //found } else { // not found } }
•
•
•
•
To get word by word then search on specific word
C# Syntax (Toggle Plain Text)
int GetWordIndex(string word) { char[] splitters = new char[]{' '}; string[] wordsArr = RichTextBox1.Text.Split(splitters, StringSplitOptions.RemoveEmptyEntries); for(int i=0; i< wordsArr.Length; i++) if(string.Equals(wordsArr[i], word, StringComparison.InvariantCultureIgnoreCase)) return i; return -1; //indicates there is no match }
c# Syntax (Toggle Plain Text)
private void button2_Click(object sender, EventArgs e) { string input = richTextBox1.Text; string[] words = System.Text.RegularExpressions.Regex.Split(input, @"\W+", System.Text.RegularExpressions.RegexOptions.Multiline); }
He can also add in splitters what you need
It may be also array of string to have something like that ("\r\n") if you read from text files.
It may be also array of string to have something like that ("\r\n") if you read from text files.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
![]() |
Similar Threads
- Adding LinkLabel-s to RichTextBox (C#)
- VB 2005 - Slow , Sloooow Text Program (VB.NET)
- Cursor won't move to the end of the text input in div withstyle.filter in IE6 & 7 (JavaScript / DHTML / AJAX)
- Extrace Pattern(E-mail ID) from text file (Perl)
- Text file Mainipulation (C++)
- formatting text in richtextbox control (VB.NET)
- Encrypting and Decrypting text from file using keyword (C)
- Cursor control in text boxes: (HTML and CSS)
Other Threads in the C# Forum
- Previous Thread: establishing USB connection from front end
- Next Thread: C# Preforming Caluclations With Controls Created In Runtime
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption event excel file files form format forms function gdi+ httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






