How to change the cursor when the mouse pointer is over a bold word in a RichTextBox?

I want to change the cursor to HAND when the mouse pointer is over the word bold in the RichTextBox. How to do it?

+3
source share
2 answers

Add this function to the richtextbox.OnMouseMove event.

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 highlighted.

+5
source
+1
source

All Articles