/// <summary>
/// 获取richTexBox行的字符长度
/// </summary>
/// <param name="rowNun"></param>
/// <returns></returns>
private Int32 GetLineCharacterCount(int rowNun)
{
String[] lines = log_textbox.Lines;
if (rowNun < 0 || rowNun > lines.Length - 1)
{
return -1;
}
return lines[rowNun].Length;
}
private void log_textbox_MouseDoubleClick(object sender, MouseEventArgs e)
{
Int32 lineNum = log_textbox.GetLineFromCharIndex(log_textbox.SelectionStart);//获取首行的行号
Int32 lineCharCount = GetLineCharacterCount(lineNum);//
if (lineCharCount < 0)
{
MessageBox.Show("文本框里没有数据!", "提示");
return;
}
int selectStart = log_textbox.GetFirstCharIndexFromLine(lineNum);
log_textbox.Select(selectStart, lineCharCount);
}