
C# Winform mouse cursor style setting method
The default mouse cursor style is a white arrow in Winform, and it does not change to a finger shape when moved to the button. It is not easy to distinguish whether it can be clicked(especially when the button style is not the default). If the mouse cursor is moved over the button, it will automatically change into a finger shape, like a link in a web page, it is easy to distinguish whether it can be clicked, regardless of whether the button style is completely changed (for example: the style is set to Flat or Popup, and the background color is replaced by the background image).
There are two methods for setting mouse cursor style in C# Winform, one: set in the control properties; the second: set with code. The following are the specific setting steps and implementation codes of these two methods.
I. Set mouse cursor style with properties in C# Winform
1. Select the button, move the mouse to the "Properties" window on the right to expand it(Or right-click the button, select "Properties" in the pop-up menu, or select "View → Properties Window"), as shown in Figure 1:
Figure 1
2. Click the drop-down list box to the right of the Cursor property, drag the slider on the right to the bottom, and select Hand.
3. After saving and regenerating, move the mouse to the button to see if it has automatically changed into a finger shape.
II. Set mouse cursor style with code in C# Winform
1. Select the button, expand the "Properties" window on the right, and select the Event icon, as shown in Figure 2:
Figure 2
2. Add button1_MouseMove to the right of MouseMove, click anywhere to open the background code window, and add the following code to the button1_MouseMove event:
private void button1_MouseMove(object sender, MouseEventArgs e)
{
Cursor.Current = Cursors.Hand;//Set the mouse to finger shape
}
-
Related Reading
- C# Read and write to text file Newline, with one lin
- C# Winform button transparent background with proper
- Bubble sort algorithm example in C# and C (Ascending
- C# if else vs switch, which efficiency is high(multi
- C# label control, with winforms label transparent ba
- C# Richtextbox change font color, add and foreach li
- C# Winforms textbox focus(2 methods)
- C# sort files or folders by name, date and creation
- Three methods of Hashtable sort by key or value in C
- C# Windows Forms foreach controls, with Textbox and
- C# sorted dictionary by value, key or length of the
- C# Winforms panel border, with color, style, thickne