2011-03-01 211 views

回答

0

好吧,那麼也許這(found here):

private void richTextBox1_MouseClick(object sender, MouseEventArgs e, Color color) 
{ 
    int firstcharindex = richTextBox1.GetFirstCharIndexOfCurrentLine(); 
    int currentline = richTextBox1.GetLineFromCharIndex(firstcharindex); 
    string currentlinetext = richTextBox1.Lines[currentline]; 
    richTextBox1.SelectionBackColor = color; 
    richTextBox1.Select(firstcharindex, currentlinetext.Length); 
} 

,那麼你必須設置顏色這個片段應該解決您的問題;-)

1

不,你首先要選擇線路:

public void MarkSingleLine() 
{ 
    int firstCharOfLineIndex = myRichTextBox.GetFirstCharIndexOfCurrentLine(); 
    int currentLine = richTextBox1.GetLineFromCharIndex(firstCharOfLineIndex); 
    this.myRichTextBox.Select(firstCharOfLineIndex, currentLine); 
    this.myRichTextBox.SelectionBackColor = Color.Aqua; 
    this.myRichTextBox.Select(0, 0); 
} 
相關問題