Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 03-01-2009
Member
 
Join Date: Dec 2008
Posts: 12
Changing A Mouse Cursor using C# Code.

I am developing a new project using C#.
I am trying to assign a curcer to a form...and i just cant do it due to me being quite a beginer but if someone could help that would be great.
So far i have search this code but it is not working,

Code:
Private Sub Game_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Cursor = ("C:\Documents and Settings\Oliver C\Desktop\Programing\Projects\VRange\0,CD.cur")
End Sub
Reply With Quote
  #2  
Old 03-01-2009
Member
 
Join Date: Jan 2008
Posts: 1,515
Re: Changing A Mouse Curcer using C# Code.

Code:
Private Sub Game_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Cursor = ("C:\Documents and Settings\Oliver C\Desktop\Programing\Projects\VRange\0,CD.cur")
End Sub
First thing I noticed is that the above stated code is in Visual Basic since it uses Private Sub and End Sub.
So we must change that to C# code,

Code:
private void Game_Load(object sender, EventArgs e)
{
Cursor myCursor = new Cursor(@"C:\Documents and Settings\Oliver C\Desktop\Programing\Projects\VRange\0,CD.cur");
someControl.cursor = myCursor; //Replace someControl !
}
I hope now you will not get any error after using this code.
Reply With Quote
  #3  
Old 03-01-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: Changing A Mouse Curcer using C# Code.

When including a path in C# you have to escape the \ character as \\ or you could place an @ in front of the path.
for example:

Cursor = ("C:\\Documents and Settings\\Oliver C\\Desktop\\Programing\\Projects\\VRange\\0,CD.cur");

OR

Cursor = (@"C:\Documents and Settings\Oliver C\Desktop\Programing\Projects\VRange\0,CD.cur");
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Changing A Mouse Cursor using C# Code."
Thread Thread Starter Forum Replies Last Post
Apple Magic Mouse: after Lion update, Mouse Cursor Jumping to Corners. Acardi !! Hardware Peripherals 10 01-10-2011 04:08 PM
Need information about the cursor changing in Pro Evolution Soccer 2012 Christabel Video Games 4 22-09-2011 07:31 PM
Changing the Cursor shape in Java rashmi_ay Software Development 4 30-11-2009 10:58 AM
Move Cursor without using a Mouse Itronix Tips & Tweaks 2 14-03-2009 01:38 PM
Mouse Cursor freezes? Help? akbar Windows XP Support 3 01-03-2007 08:43 PM


All times are GMT +5.5. The time now is 10:59 PM.