2013-10-28 2 views
1

특정 줄의 글꼴을 변경하고 싶습니다. 내 코드는 여기에 ...RichTextBox -> 특정 줄의 글꼴 변경

string[] textBoxLines = richTextBox1.Lines; 
foreach (string line in textBoxLines) 
{ 
    if(line.StartsWith("-->")) 
    { 
    //here is my problem, how to can change the font in the spectific line... 
    } 
} 

답변

2
string[] textBoxLines = richTextBox1.Lines; 
for (int i = 0; i < textBoxLines.Length; i++) 
{ 
    string line = textBoxLines[i]; 
    if (line.StartsWith("-->")) 
    { 
     richTextBox1.SelectionStart = richTextBox1.GetFirstCharIndexFromLine(i); 
     richTextBox1.SelectionLength = line.Length; 
     richTextBox1.SelectionFont = yourFont; 
    } 
} 
richTextBox1.SelectionLength = 0;//Unselect the selection