[英]How to change cursor when mouse pointer is over a bold word in RichTextBox?
I want to change cursor to the HAND when mouse pointer is over a bold word in RichTextBox. 我希望当鼠标指针位于RichTextBox中的粗体字上时,将光标更改为HAND。 How to do this?
这该怎么做?
Add this function to richtextbox.OnMouseMove event. 将此函数添加到richtextbox.OnMouseMove事件。
private void richTextBox2_MouseMove(object sender, MouseEventArgs e)
{
int c = richTextBox2.GetCharIndexFromPosition(new Point(e.X, e.Y));
richTextBox2.Select(c, 1);
if (richTextBox2.SelectionFont.Bold)
{
richTextBox2.Cursor = Cursors.Hand;
}
else
{
richTextBox2.Cursor = Cursors.Default;
}
}
You just need 1 char to know if it is bold. 你需要1个字符才能知道它是否是粗体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.