Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to set an image in Mouse cursor in C# windows form?
Posted
Comments
Arsalaan Ahmed 19-Oct-12 3:20am    
sory my mistake its cursor not a cusor.......
Nelek 23-Oct-12 3:20am    
No problem. If you want to correct it, you can use the "improve question" widget at the bottom of your message

1 solution

When the control is created change the property of Cursor.
As input to a Cursor class you can use a string path to a cursor file.

C#
Cursor = new Cursor("cursor.cur");


The picture can be any picture for example jpeg, however it needs to bee small. I used a 10px times 10px picuture
 
Share this answer
 
v3
Comments
Arsalaan Ahmed 19-Oct-12 12:14pm    
Cursor obj = new Cursor(@"C:\Resource\pic.jpg");
this code i am write.. so this error is occur....
Image format is not valid. The image file may be corrupted.
Parameter name: stream
what i do..
Perić Željko 19-Oct-12 12:16pm    
It seems that you can't set "jpg" file as cursor, but You can use any *.ico (Icon) file to set different picture to mouse pointer: Cursor red_horizontal_ico; red_horizontal_ico = new Cursor("Graphics\\Linkage red icon horizontal.ico"); try link http://msdn.microsoft.com/en-us/library/4w858ek0(v=vs.80).aspx
Arsalaan Ahmed 19-Oct-12 12:42pm    
i am really really sory i cant understand what u say.. And i am write this code Could not find a part of the path 'C:\Users\EmRaan\documents\visual studio 2010\Projects\WindowsFormsApplication15\WindowsFormsApplication15\bin\Debug\Graphics\Brainy.ico'. again error occur...
Arsalaan Ahmed 19-Oct-12 12:44pm    
and i am use icon...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900