Je suis en train de faire une trouvaille, trouver la fonction suivante pour mon programme, que j'ai réussi à faire avec ce code:Trouver, Trouver Suivant?
int findPos = 0;
private void button1_Click(object sender, EventArgs e)
{
try
{
string s = textBox1.Text;
richTextBox1.Focus();
findPos = richTextBox1.Find(s, findPos, RichTextBoxFinds.None);
richTextBox1.Select(findPos, s.Length);
findPos += textBox1.Text.Length;
//i = richTextBox1.Find(s, i + s.Length, RichTextBoxFinds.None);
}
catch
{
MessageBox.Show("No Occurences Found");
findPos = 0;
}
}
Et il fonctionne très bien dans form1 mais si j'utilise ce code et essayez d'appeler il de form2 Il ne fait rien:
//Form1
public void FindNext()
{
try
{
this.Focus();
Form2 frm2 = new Form2();
string s = frm2.textBox1.Text;
richTextBox1.Focus();
findPos = richTextBox1.Find(s, findPos, RichTextBoxFinds.None);
richTextBox1.Select(findPos + 1, s.Length);
findPos += textBox1.Text.Length;
}
catch
{
MessageBox.Show("No Occurences Found");
findPos = 0;
}
}
//Form2
private void button1_Click(object sender, EventArgs e)
{
Form1 frm1 = new Form1();
frm1.FindNext();
}
Est-ce que quelqu'un sait pourquoi c'est? Merci, Tanner.
** S'il vous plaît ** Le nom de votre formulaires et des contrôles. – SLaks