2013-08-10 3 views
1

У меня есть richTextBox и имеет более 50 строк ... Мне нравится удалять строки с помощью MOVE STORAGE. Например, под первой строкой слов (в самом богатом текстовом поле есть две строки) с конечным полутоном имеет слово MOVE STORAGE, чем удалить все 2 строки.удалить строки из RichtextBox?

ALTER TABLE "CAMPUS_SITE" MOVE STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT); 

DROP INDEX XIE2TBL_A; 
DROP INDEX XPKTBL_A; 

Ожидаемый результат:

DROP INDEX XIE2TBL_A; 
DROP INDEX XPKTBL_A; 
+0

Вы хотите, чтобы это регулярное выражение? –

+0

На самом деле у вас есть 4 строки, пустая строка также там вы хотите удалить это тоже? –

ответ

2

Ваш вопрос, кажется, что вы хотите удалить строку, содержащую «MOVE ХРАНЕНИЯ» .Вы должны попробовать это;

var text = "";//Holds the text of current line being looped. 
     var startindex = 0;//The position where selection starts. 
     var endindex = 0;//The length of selection. 

     for (int i = 0; i < richTextBox1.Lines.Length; i++)//Loops through each line of text in RichTextBox 
     { 
      text = richTextBox1.Lines[i];//Stores current line of text. 
      if (text.Contains("MOVE STORAGE") == true)//Checks if the line contains MOVE STORAGE. 
      { 
       startindex = richTextBox1.GetFirstCharIndexFromLine(i);//If match is found the index of first char of that line is stored in startindex. 
       endindex = text.Length;//Gets the length of line till semicolon and stores it in endindex. 
       richTextBox1.Select(startindex, endindex);//Selects the text. 
       richTextBox2.Text = richTextBox1.Text.Replace(richTextBox1.SelectedText, string.Empty);//Replaces the text with empty string. 
      } 
     } 
Смежные вопросы