111,123
社区成员
发帖
与我相关
我的任务
分享
private void textBox1_MouseMove(object sender, MouseEventArgs e)
{
int start = textBox1.SelectionStart;
int length = textBox1.SelectionLength;
//获取选择字符串的矩形
Rectangle rect = new Rectangle();
rect.X = start * 6;//6是单个字符的宽度
rect.Y = 0;
rect.Width = length * 6;
rect.Height = 14;//14是单个字符的高度
//判断矩形是否包含鼠标坐标
if (rect.Contains(e.Location))
Console.WriteLine(rect + " " + i++);
}