Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Hello!
 
I try to write, code for search in rich text box like search in notepad but I have some of errors.
in my rich text box is text that they are response of web page. and maybe text changed.
how can I write a search text in richtextbox with c# that include ring ( for , while , ... ).
 
please help me.
Thank you!
Posted 6-May-13 19:23pm
e.v.r412
Comments
s_mon at 7-May-13 1:03am
   
Sorry to ask, but is it ASP.Net or plain WinForms? And what errors do you have?
e.v.r at 7-May-13 1:14am
   
Thank you!
no, my program is application that work in network, and crawl in html code and find links. so i have request / response we page. now my response is in rich text box. now i want saerch any word for example ( html, ).
i want a search like search in notepad.
 
e.v.r at 7-May-13 1:16am
   
my code is here.
 
public partial class Form1 : Form
{
int start = 0;
int indexOfSearchText = 0;

public int FindText(string txtToSearch, int searchStart, int searchEnd)
{
 
if (searchStart > 0 && searchEnd > 0 && indexOfSearchText >= 0)
{
XSSResponceRichTextBox.Undo();
}
 
int retVal = -1;
 
if (searchStart >= 0 && indexOfSearchText >= 0)
{
 
if (searchEnd > searchStart || searchEnd == -1)
{
 
indexOfSearchText = XSSResponceRichTextBox.Find(txtToSearch, searchStart, searchEnd, RichTextBoxFinds.None);
 
if (indexOfSearchText != -1)
{
retVal = indexOfSearchText;
}
 
// if (indexOfSearchText == -1)
else
{
searchStart = 0;
indexOfSearchText = XSSResponceRichTextBox.Find(txtToSearch, searchStart, searchEnd, RichTextBoxFinds.None);
retVal = indexOfSearchText;
}
 
//if (indexOfSearchText == -1)
//{
// searchStart = 0;
// indexOfSearchText =XSSResponceRichTextBox.Find(txtToSearch, searchStart, searchEnd, System.Windows.Forms.RichTextBoxFinds.None);
// retVal = indexOfSearchText;
//}
}
}
 
return retVal;
}
 
public Form1()
{
InitializeComponent();
}
 
private void txtSearch_TextChanged(object sender, EventArgs e)
{
if (start != 0)
{
XSSResponceRichTextBox.Undo();
start = 0;
indexOfSearchText = 0;
}
}
 

 
private void txtSearch_KeyPress(object sender, KeyPressEventArgs e)
{
int startindex = 0;
 
if (e.KeyChar == ">
Shriniwas Shukla at 7-May-13 13:32pm
   
what error are you getting from this code?
e.v.r at 8-May-13 3:07am
   
My code can not run to my application.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 215
1 George Jonsson 175
2 Kornfeld Eliyahu Peter 159
3 PIEBALDconsult 110
4 Richard MacCutchan 85
0 OriginalGriff 6,080
1 DamithSL 4,648
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,624
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 7 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100