1.获取text
2. 用indexof方法查找
3 用SelectionStart定位
4. 用SelectionLength 选中,就ok了
StreamReader srlog = new StreamReader(logDir + lstLoglist.Items[lstLoglist.SelectedIndex].ToString() + ".log");
string readLine;
while( (readLine = srlog.ReadLine()) != null ){
if (readLine.IndexOf("VC->BTM") != -1)
{
rtbLoglist.SelectionStart = readLine.IndexOf("VC->BTM", 0, 7);
rtbLoglist.SelectionLength = 7;
rtbLoglist.AppendText(readLine + "\n");
}
}
srlog.Close();