A cursor in Windows is an icon that is displayed when you move a mouse, a pen, or a trackball. Usually, a different cursor image is displayed for different activity. For instance, the default cursor is different than a wait cursor.
Cursors may be different for different operating systems. Figure 1 displays some of the cursors available on machine loaded with Windows 7 operating system. As you can presume from Figure 1, the Default cursor is loaded most of the time, the AppStarting cursor is displayed when any application is starting and loading, and the Size cursors are loaded when you are resizing an application.
Figure 1
Windows Forms allows us to change this cursor image using the Cursor and its related classes and enumerations.
In this article, I will demonstrate how to apply and manage cursors in your Windows Forms applications.
Setting Cursor of Controls
In Windows Forms, all Windows controls are derived from the Control class. The Control class has a Cursor property that represents a cursor respective to that control. That means, each control can have its own cursor. So the default cursor on a Form can be different than the default cursor on a child control on the same Form. The Cursor property is of type Cursors class.
For example, the following code snippet sets default cursor of a Button and a ListBox control to Hand and No respectively. So when you rollover on button1 control, you will see hand cursor and when you rollover on listBox1 control, you will see a No cursor. You may use the same approach to define a cursor for any control.
- button1.Cursor = Cursors.Hand;
- listBox1.Cursor = Cursors.No;
Cursors Class
The Cursors class provides a set of cursors that can be used in Windows Forms. Each cursor is represented by a static property. Here is a list of cursors with brief description as described in MSDN.
- AppStarting - Gets the cursor that appears when an application starts.
- Arrow - Gets the arrow cursor.
- Cross - Gets the crosshair cursor.
- Default - Gets the default cursor, which is usually an arrow cursor.
- Hand - Gets the hand cursor, typically used when hovering over a Web link.
- Help - Gets the Help cursor, which is a combination of an arrow and a question mark.
- HSplit - Gets the cursor that appears when the mouse is positioned over a horizontal splitter bar.
- IBeam - Gets the I-beam cursor, which is used to show where the text cursor appears when the mouse is clicked.
- No - Gets the cursor that indicates that a particular region is invalid for the current operation.
- NoMove2D - Gets the cursor that appears during wheel operations when the mouse is not moving, but the window can be scrolled in both a horizontal and vertical direction.
- NoMoveHoriz - Gets the cursor that appears during wheel operations when the mouse is not moving, but the window can be scrolled in a horizontal direction.
- NoMoveVert - Gets the cursor that appears during wheel operations when the mouse is not moving, but the window can be scrolled in a vertical direction.
- PanEast - Gets the cursor that appears during wheel operations when the mouse is not moving, but the window can be scrolled in a horizontal direction.
- PanNE - Gets the cursor that appears during wheel operations when the mouse is moving and the window is scrolling horizontally to the right.
- PanNorth - Gets the cursor that appears during wheel operations when the mouse is moving and the window is scrolling horizontally and vertically upward and to the right.
- PanNE - Gets the cursor that appears during wheel operations when the mouse is moving and the window is scrolling vertically in an upward direction.
- PanNW - Gets the cursor that appears during wheel operations when the mouse is moving and the window is scrolling horizontally and vertically upward and to the left.
- PanSE - Gets the cursor that appears during wheel operations when the mouse is moving and the window is scrolling horizontally and vertically downward and to the right.
- PanSouth - Gets the cursor that appears during wheel operations when the mouse is moving and the window is scrolling vertically in a downward direction..
- PanSW Gets the cursor that appears during wheel operations when the mouse is moving and the window is scrolling horizontally and vertically downward and to the left.
- PanWest - Gets the cursor that appears during wheel operations when the mouse is moving and the window is scrolling horizontally to the left.
- SizeAll - Gets the four-headed sizing cursor, which consists of four joined arrows that point north, south, east, and west.
- SizeNESW - Gets the two-headed diagonal (northeast/southwest) sizing cursor
- SizeNS - Gets the two-headed vertical (north/south) sizing cursor.
- SizeNWSE - Gets the two-headed diagonal (northwest/southeast) sizing cursor.
- SizeWE - Gets the two-headed horizontal (west/east) sizing cursor.
- UpArrow - Gets the up arrow cursor, typically used to identify an insertion point.
- VSplit - Gets the cursor that appears when the mouse is positioned over a vertical splitter bar.
- WaitCursor - Gets the wait cursor, typically an hourglass shape.


Manjit HadaPosted Nov 30, 2019, 12:12 AM
How to reset command to move pen to initial position at top left of the screen
hps shahPosted Jul 2, 2019, 11:37 PM
Very useful article.
Corné AspelingPosted Sep 28, 2017, 5:04 PM
How would you assert custom mouse image has changed in a test assert when I do not see how to get hold of anything other than the cursor state?
Former memberPosted Jul 25, 2015, 7:14 AM
We can set current cursor by using this code ,this.Cursor = Cursors.WaitCursor; but how can we get current cursor type. I want to get current cursor type and then perform some action based on the cursor type. I tried this but does not work var CurType=this.cursor; if(CurType==Cursors.Hand){//some code}
marco canazzaPosted Apr 16, 2015, 12:17 PM
hi man! i have c# 2010 express but i cannot found "Cursor File" on the visual c# item list, can you tell me how to install or find that? thanks!
Saineshwar BageriPosted Jun 13, 2014, 12:32 AM
Nice example sir
Prerana TiwariPosted Jun 12, 2014, 11:00 PM
Nice one sir..........
move backPosted Feb 29, 2012, 8:44 AM
hey, this is for windows application. i need to set the cursor position for web application. how to do that? really need help
Fred SanderseditedPosted Dec 13, 2011, 6:05 PMEdited Dec 13, 2011, 6:07 PM
The problem with creating a custom cursor with the Visual Studio bitmap editor is that when you create a cursor using the resultant .CUR file, the hotspot is always at (0,0), regardless of where you set it with the hotspot tool.
Ricky DowlatrameditedPosted Nov 7, 2011, 9:27 AMEdited Nov 7, 2011, 9:34 AM
Hi, I want to place a cursor in a certain texbox in a webapplication. Can anybody help me. C# code please.
Abdullah AKALINPosted Jun 16, 2010, 5:12 AM
Thanks...
Abdullah AKALINPosted Jun 15, 2010, 3:38 PM
Hmm...I've got VisualStudio 2008...Where can I find Visual Studio 2010 express edition?
Abdullah AKALINPosted Jun 15, 2010, 2:26 PM
I've tried to manage it but I couldn't.Because my Visual C# Express Edition doesn't have this template.Where can I find this template? Thanks... (sorry for my English)