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".
SamPosted Aug 14, 2007, 6:01 AM
Hi,
Is there something wrong with the inbuilt methods:
rtb.Find(AString , StartIndex, EndIndex, RichTextBoxFinds.None);
rtb.Find(AString, StartIndex, EndIndex, RichTextBoxFinds.Reverse);
Sam.
Ryan TurneyPosted Aug 13, 2007, 11:32 PM
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.
Jan MontanoPosted Aug 13, 2007, 10:39 PM
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