The Find method searches the whole string of the RichTextBox control if the start parameter is equal to the end parameter (814317)
The information in this article applies to:
- Microsoft Visual Studio .NET (2003), Professional Edition
- Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2003), Academic Edition
- Microsoft Visual Studio .NET (2002), Professional Edition
- Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2002), Academic Edition
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual C# 2005, Express Edition
- Microsoft Visual C# .NET (2003)
- Microsoft Visual C# .NET (2002)
SYMPTOMSThe Find method of the RichTextBox control searches for the text that is specified in the str parameter, and then returns the first character location of the
search string in the control. When the Find method searches for a string that is not in the text of the
control, the Find property returns -1. When you use an overloaded RichTextBox control Find method as RichTextBox1.Find (string, start, end, options), and you specify the same value for the start parameter and the end parameter, the Find method searches all the text starting from the zero position.
Therefore, the Find method returns the position of the search string that starts at
the zero position. Similar behavior occurs when you set the start position of
the RichTextBox.Find method to RichTextBox.Text.Length.CAUSEWhen you set the start parameter as RichTextBox.Text.Length, or
you set the start parameter and end parameter to the same value, the common language runtime
internally calls the Find method (string, RichTextBox.Text.Length, RichTextBox.Text.Length, options). When you set the start and end parameters to the length of the text, the Find method searches all the text in the RichTextBox control. When you call an overloaded Find method (string, start, options), the common language runtime internally calls the Find method (string, start, -1, options). Similarly, when you call an overloaded Find method (charset, start), the common language runtime calls Find (charset, start, -1). Therefore, all the text is searched.WORKAROUNDTo work around this problem, set the end parameter to a value that is one greater than the start parameter while you call the Find method. For example, do not use the following call to the Find method: Find(String, RichTextBox.Text.Length, options) Instead, use this Find method code: Find(String, RichTextBox.Text.Length, RichTextBox.Text.Length+1, options) STATUS This
behavior is by design.
Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
---|
Keywords: | kbvs2005applies kbvs2005swept kbWindowsForms kbControl kbCtrl kbprb KB814317 kbAudDeveloper |
---|
|