Click here to Skip to main content
15,898,938 members
Home / Discussions / C#
   

C#

 
AnswerRe: richTextBox problem 2 Pin
Luc Pattyn27-May-11 2:35
sitebuilderLuc Pattyn27-May-11 2:35 
GeneralRe: richTextBox problem 2 Pin
_Q12_27-May-11 6:35
_Q12_27-May-11 6:35 
AnswerRe: richTextBox problem 2 Pin
Luc Pattyn27-May-11 6:39
sitebuilderLuc Pattyn27-May-11 6:39 
GeneralRe: richTextBox problem 2 Pin
Dan Mos27-May-11 9:28
Dan Mos27-May-11 9:28 
GeneralRe: richTextBox problem 2 Pin
_Erik_27-May-11 3:25
_Erik_27-May-11 3:25 
GeneralRe: richTextBox problem 2 Pin
_Q12_27-May-11 8:05
_Q12_27-May-11 8:05 
AnswerRe: richTextBox problem 2 Pin
BobJanova27-May-11 5:03
BobJanova27-May-11 5:03 
AnswerRe: richTextBox problem 2 Pin
_Q12_27-May-11 7:59
_Q12_27-May-11 7:59 
Problems Solved:
Sincerely, I did changed RichTextBoxFinds.None before posting here on forum, but for some strange reason, it did not work back then... Now it works fine.
I have another problem...see it beneath code.

Here is the functional code:
int posTxt = 0; string tempText = "";
        private void button2_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = tempText;//somewhere in the page load : tempText = richTextBox1.Text;

            string searchText = textBox2.Text.ToLower();
            string alltxt = richTextBox1.Text.ToLower();

            if (alltxt.Contains(searchText))
            {
                //problems at start
                if (posTxt <= 0)
                {
                    richTextBox1.Text = richTextBox1.Text.Insert(0, " "); 
                    posTxt = 1;
                }
                //colorization at found text 
                while (posTxt > 0)
                {
                    posTxt = richTextBox1.Find(searchText, posTxt, RichTextBoxFinds.None);
                    if (richTextBox1.SelectedText.ToLower() == searchText)
                    {
                        richTextBox1.SelectionLength = searchText.Length;
                        richTextBox1.SelectionColor = Color.Red;
                    }
                    posTxt = richTextBox1.Find(searchText, posTxt + 1, RichTextBoxFinds.None);
                }
            }
            posTxt = 0;
        }


But i have a little problem now...
If I load a *.rtf file with formatting text and search a word in that richTextBox1 that show that file, the text is re-formatting, loosing its original format.
How to maintain its original format, and select as usual(with red marking)?
QuestionError running sp in C# Pin
MAW3026-May-11 16:31
MAW3026-May-11 16:31 
AnswerRe: Error running sp in C# PinPopular
Richard MacCutchan26-May-11 22:16
mveRichard MacCutchan26-May-11 22:16 
QuestionUserAppDataRegistry - disable ProductVersion component in key path Pin
bob1697226-May-11 15:41
bob1697226-May-11 15:41 
QuestionRegEx for Fist Charactr is Positive Pin
Kevin Marois26-May-11 11:31
professionalKevin Marois26-May-11 11:31 
AnswerRe: RegEx for Fist Charactr is Positive Pin
Luc Pattyn26-May-11 12:00
sitebuilderLuc Pattyn26-May-11 12:00 
GeneralRe: RegEx for Fist Charactr is Positive Pin
Manfred Rudolf Bihy26-May-11 12:26
professionalManfred Rudolf Bihy26-May-11 12:26 
GeneralRe: RegEx for Fist Charactr is Positive [modified] Pin
Luc Pattyn26-May-11 12:40
sitebuilderLuc Pattyn26-May-11 12:40 
GeneralRe: RegEx for Fist Charactr is Positive Pin
SledgeHammer0126-May-11 12:59
SledgeHammer0126-May-11 12:59 
AnswerRe: RegEx for Fist Charactr is Positive Pin
Luc Pattyn26-May-11 13:04
sitebuilderLuc Pattyn26-May-11 13:04 
GeneralRe: RegEx for Fist Charactr is Positive Pin
SledgeHammer0126-May-11 13:13
SledgeHammer0126-May-11 13:13 
GeneralRe: RegEx for Fist Charactr is Positive Pin
BobJanova26-May-11 23:31
BobJanova26-May-11 23:31 
AnswerRe: RegEx for Fist Charactr is Positive Pin
Manfred Rudolf Bihy26-May-11 12:22
professionalManfred Rudolf Bihy26-May-11 12:22 
GeneralRe: RegEx for Fist Charactr is Positive Pin
Luc Pattyn26-May-11 13:01
sitebuilderLuc Pattyn26-May-11 13:01 
GeneralRe: RegEx for Fist Charactr is Positive Pin
Manfred Rudolf Bihy26-May-11 13:25
professionalManfred Rudolf Bihy26-May-11 13:25 
AnswerRe: RegEx for Fist Charactr is Positive Pin
BobJanova26-May-11 23:33
BobJanova26-May-11 23:33 
QuestionExecuting Javascript Pin
mjackson1126-May-11 10:00
mjackson1126-May-11 10:00 
AnswerRe: Executing Javascript Pin
BobJanova26-May-11 23:38
BobJanova26-May-11 23:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.