2011-03-01 174 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); 
} 
相关问题