Hello, I am having problems with creating find function. I can get the code to find starting from the top going down, but I haven't been able to reverse that, take a look.
else
if (upRadioButton.Checked == true){
try{
rtb.Select(rtb.Text.Length, length);
// rtb.Select(searchindex - 1, length);searchindex = temp.LastIndexOf(textBox1.Text, searchindex);
rtb.Select(searchindex, length);
rtb.Focus();
searchindex += length;
}
catch (Exception e){
MessageBox.Show(e.Message);}
}
Thanks for any help you can give, this should be simple. I'm just having a "I don't get it day".

Jan MontanoRank #1,295 · 1.3K reputationPosted Aug 13, 2007, 6:39 PM EDT
Have you already solved your problem? Maybe if you'll include the definition of each of the variables in your code snippet and also their current values, we might be able to help you.
Cheers,
Jan
Ryan TurneyRank #7,345 · 243 reputationPosted Aug 13, 2007, 7:32 PM EDT
Wow, I'm sorry I didn't even notice I forgot all the definitions, thanks for telling me.
namespace
Simple_Pad{
public partial class FindAndReplace : Form{
private
string FindText = ""; private int searchindex;private
void Find(){
RichTextBox
rtb = (RichTextBox)_tabs.SelectedTab.Controls[0]; int length = textBox1.Text.Length; string temp = rtb.Text;else
if (upRadioButton.Checked == true){
try{
rtb.Select(searchindex, length);
searchindex = temp.LastIndexOf(textBox1.Text, searchindex);
rtb.Select(searchindex, length);
rtb.Focus();
searchindex += length;
}
catch (Exception e){
MessageBox.Show(e.Message);}
}
}
}
}
That should be everything, I haven't solved it quite yet. I found more bugs in the current program and have been working to solve those. Thanks.
Sam112 reputationPosted Aug 14, 2007, 2:01 AM EDT
Hi,
Is there something wrong with the inbuilt methods:
rtb.Find(AString , StartIndex, EndIndex, RichTextBoxFinds.None);
rtb.Find(AString, StartIndex, EndIndex, RichTextBoxFinds.Reverse);
Sam.