2016-09-15 1 views
0
namespace PostingQueueMonitoring_V2 
{ 
    public partial class Helper : Form 
    { 
     public Helper() 
     { 
      InitializeComponent(); 
     } 

     private void button1_Click(object sender, EventArgs e) 
     { 
      if (String.IsNullOrEmpty(input_richTextBox1.Text.Trim())) 
      { 
       MessageBox.Show("Please input text..."); 
       return; 
      } 

      string[] myText = new string[] {input_richTextBox1.Text}; 
      foreach (string element in myText) 
      { 
       output_richTextBox2.Text = element; 
       System.Console.WriteLine(output_richTextBox2.Text); 
      } 
      System.Console.WriteLine(); 
      //output_richTextBox2.Rtf = input_richTextBox1.Rtf; 
     } 

     private void Helper_Resize(object sender, EventArgs e) 
     { 
      this.MinimumSize = new Size(736, 466); 
      this.MaximumSize = new Size(736, 466); 
     } 
    } 
} 

input_richTextBox1에서 텍스트 서식을 지정하고 output_richTextBox2에 표시된 코드를 업데이트하는 방법. 아래 예.RichTextBox에서 줄 값의 문자열을 추가하는 방법

input_richTextBox1 : 애플 \ BANNA \ n 코코넛 \ n 두리안 \ n N 오렌지

예상 output_richTextBox2 ('애플', 'BANNA', '코코넛'로 결과, '두리안' '오렌지')

+0

당신은 무엇을하려고 했습니까? –

+0

I "는 ("+ 원소 + ")"output_richTextBox2.Text = 시도; 그러나 그것은 내가 기대했던 것이 아니다. 검색은 동일한 요청이지만 행운은 없습니다. – deadlock

+0

는 텍스트 속성을 수정하지 마십시오 또는 당신이 엉망으로 모든 서식을 것입니다! 사항 String.split 및 RTB.Append으로 봐 – TaW

답변

0

이 항목을 사용해보세요.

 private void button1_Click(object sender, EventArgs e) 
    { 
     if (String.IsNullOrEmpty(richTextBox1.Text.Trim())) 
     { 
      MessageBox.Show("Please input text..."); 
      return; 
     } 

     var textValues = richTextBox1.Text.Split('\n').Select(txt => $"'{txt}'"); 
     var concatValues = string.Join(",", textValues); 
     richTextBox2.Text = concatValues; 
     System.Console.WriteLine(); 
    } 
관련 문제