Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the cursor on hover in C#

Tags:

c#

winforms

I can't find out on how I can change my cursor to a "pointer" or whatever it's called while hovering an image.

I have tried with MouseOver but I can't get it to work. Here's my current code;

private void image_Phone_MouseOver(object sender, EventArgs e)
{
    Cursor.Current = Cursors.Hand;
}

However, the cursor doesn't change.

like image 305
Chris Meller Avatar asked Sep 13 '16 15:09

Chris Meller


People also ask

How do I change the hover arrow?

How to Change the Cursor of Hyperlink while Hovering. The default cursor for a hyperlink is "pointer". To change it, you need to specify the cursor type for your <a> element with the CSS :hover selector. In our example, we style only the "link" class.

How do I change the cursor when I hover over the button?

Answer: Use the CSS cursor Property You can simply use the CSS cursor property with the value pointer to change the cursor into a hand pointer while hover over any element and not just hyperlink.

What is hover the cursor?

transitive verb. : to position (a computer cursor) over something (such as an image or icon) without selecting it Many in the class hovered their cursors over words and icons for long periods before committing to clicking their mouse.—


2 Answers

For any PowerShell/Windows Forms programmers:

You can use this for basically every element in your form:

$pictureBox1.Add_MouseHover({ $this.Cursor = "Hand" })
like image 181
Tobias Meyer Avatar answered Oct 04 '22 04:10

Tobias Meyer


Set appropriate cursor in control properties window.

Here's an example of setting "Hand" cursor for picturebox.

enter image description here

like image 27
rpeshkov Avatar answered Oct 04 '22 04:10

rpeshkov