943,678 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 2118
  • C# RSS
You are currently viewing page 1 of this multi-page discussion thread
Jul 14th, 2009
0

End of Text in RichTextbox

Expand Post »
Dear Friend

How can I check end of the text in rich text box using C#?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
vishalonne is offline Offline
69 posts
since Jun 2009
Jul 14th, 2009
0

Re: End of Text in RichTextbox

i dont understand your question.
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Jul 14th, 2009
0

Re: End of Text in RichTextbox

Neither me..
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Jul 14th, 2009
0

Re: End of Text in RichTextbox

no not again
ddanbe,sknake, adatapost and others will be added to list soon
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Jul 17th, 2009
0

Re: End of Text in RichTextbox

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
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
vishalonne is offline Offline
69 posts
since Jun 2009
Jul 17th, 2009
0

Re: End of Text in RichTextbox

You can copy the text from the RichTextBox into a String and search it using IndexOf method.
Reputation Points: 72
Solved Threads: 15
Junior Poster in Training
lighthead is offline Offline
64 posts
since Jan 2008
Jul 17th, 2009
1

Re: End of Text in RichTextbox

To get word by word then search on specific word
C# Syntax (Toggle Plain Text)
  1. int GetWordIndex(string word)
  2. {
  3. char[] splitters = new char[]{' '};
  4. string[] wordsArr = RichTextBox1.Text.Split(splitters, StringSplitOptions.RemoveEmptyEntries);
  5. for(int i=0; i< wordsArr.Length; i++)
  6. if(string.Equals(wordsArr[i], word, StringComparison.InvariantCultureIgnoreCase))
  7. return i;
  8. return -1; //indicates there is no match
  9. }
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Jul 17th, 2009
0

Re: End of Text in RichTextbox

What do you want to use?

c# Syntax (Toggle Plain Text)
  1. private void button1_Click(object sender, EventArgs e)
  2. {
  3. string find = "blu";
  4. if (0 <= richTextBox1.Text.IndexOf(find, StringComparison.InvariantCultureIgnoreCase))
  5. {
  6. System.Diagnostics.Debugger.Break();
  7. //found
  8. }
  9. else
  10. {
  11. // not found
  12. }
  13. }
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Jul 17th, 2009
0

Re: End of Text in RichTextbox

To get word by word then search on specific word
C# Syntax (Toggle Plain Text)
  1. int GetWordIndex(string word)
  2. {
  3. char[] splitters = new char[]{' '};
  4. string[] wordsArr = RichTextBox1.Text.Split(splitters, StringSplitOptions.RemoveEmptyEntries);
  5. for(int i=0; i< wordsArr.Length; i++)
  6. if(string.Equals(wordsArr[i], word, StringComparison.InvariantCultureIgnoreCase))
  7. return i;
  8. return -1; //indicates there is no match
  9. }
You can also use RegEx's word boundary so you can handle splitting and removing punctuation:
c# Syntax (Toggle Plain Text)
  1. private void button2_Click(object sender, EventArgs e)
  2. {
  3. string input = richTextBox1.Text;
  4. string[] words = System.Text.RegularExpressions.Regex.Split(input, @"\W+", System.Text.RegularExpressions.RegexOptions.Multiline);
  5. }
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Jul 17th, 2009
0

Re: End of Text in RichTextbox

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.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: establishing USB connection from front end
Next Thread in C# Forum Timeline: C# Preforming Caluclations With Controls Created In Runtime





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC