c# - Search and move -


i set search function search rich text box. go through text box , highlight different cases match. rich text box lists name goes next line want export not highlighted stuff whole name different text box. have far search function.

      private void search_button_click(object sender, eventargs e)        {         int index = 0;         int count = 0;         string temp = display_rich_text_box.text;         //bool k;         display_rich_text_box.text = "";         display_rich_text_box.text = temp;         string[] fullname;          while (index <= display_rich_text_box.text.lastindexof(search_text_box.text))         {             //searches , locates text searching             display_rich_text_box.find(search_text_box.text, index, display_rich_text_box.textlength, richtextboxfinds.none);              //color selection: hightlights in yellow             display_rich_text_box.selectionbackcolor = color.yellow;             count = count + 1;               fullname =  display_rich_text_box.split("\n")              //will search through rest of document or until cannot continue             index = display_rich_text_box.text.indexof(search_text_box.text, index) + 1;         }          // if (count > 0)         //{         form2 f = new form2(count.tostring(), fullname.tostring());         f.showdialog();         } 

(the text box on different form , form displays how many matches found (count)).

so tried splitting text box when breaks new line after highlights text.

ex: search fold (typed in search_text_box)

folder folder b new design pictures

so when searches highlights whats typed in search_text_box. trying split string responsible display_text_box display folder , folder b in separate text box if user types fold. text box in different form. in advance.

i have changed function split lines:

    private void search_button_click(object sender, eventargs e)     {         var lines = display_rich_text_box.text.split('\n');         var count = 0;          // text whole line (which whole name you're looking for)         foreach (string line in lines)         {             // if line doesn't have text you're looking             if (!line.contains(search_text_box.text)) continue;              count++;              // add index of whole input plus index of text within line             var index = lines.indexof(line) + line.indexof(search_text_box.text);              //searches , locates text searching             display_rich_text_box.find(search_text_box.text, index,                 display_rich_text_box.textlength, richtextboxfinds.none);              //color selection: hightlights in yellow             display_rich_text_box.selectionbackcolor = color.yellow;              //do line             var wholename = line;         }          form2 f = new form2(searchcount);         f.showdialog();     } 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -