I am trying to add a custom cursor to my winforms app

i cant figureout how to do it and when i look it up its not working
30 Replies
Angius
Angius8mo ago
What have you tried and what doesn't work?
『яє∂_ℓєgισn』
jigneshon
C# 4 All
C# Tutorial – How To Use Custom Cursors [Intermediate]
Custom cursors are something that you don’t need to use very often, but when you do need them, they can make a huge difference in the usability of your program. So today we are going to take …
『яє∂_ℓєgισn』
i bet it works i am just really confused on where to put the code snippets it puts there
Angius
Angius8mo ago
myControl there seems to be the control you want the cursor to show in So if you want it to show on the whole window, it would be the main form or whatever
Angius
Angius8mo ago
So the code would probably go into the constructor of that main form
『яє∂_ℓєgισn』
so like this one?
No description
Angius
Angius8mo ago
ye
『яє∂_ℓєgισn』
would i just putr the code with myControl in this area then?
No description
『яє∂_ℓєgισn』
but where would this part go
Cursor myCursor = new Cursor("myCursor.cur");
Cursor myCursor = new Cursor("myCursor.cur");
in the same place but a different line?
Angius
Angius8mo ago
In the constructor as well
『яє∂_ℓєgισn』
is the onstructer this part?
No description
『яє∂_ℓєgισn』
i am geussing it is\
Angius
Angius8mo ago
No
『яє∂_ℓєgισn』
oh where is the constructer
Angius
Angius8mo ago
$structure
MODiX
MODiX8mo ago
namespace Namespace;

[Attribute]
public class Class
{
public string PublicField;
private bool _privateField;

public int PublicProperty { get; set; }

public Class() {} // Constructor

public void Method(int parameter)
{
var localVariable = parameter;

int LocalMethod(string param) { return 3; }
}
}
namespace Namespace;

[Attribute]
public class Class
{
public string PublicField;
private bool _privateField;

public int PublicProperty { get; set; }

public Class() {} // Constructor

public void Method(int parameter)
{
var localVariable = parameter;

int LocalMethod(string param) { return 3; }
}
}
Angius
Angius8mo ago
Constructor is a method without a return type and with the same name as the class it's in If you don't have one, make one
『яє∂_ℓєgισn』
this part then?
No description
『яє∂_ℓєgισn』
i am really confused
Angius
Angius8mo ago
I guess InitializeComponent could work as well
Angius
Angius8mo ago
There is no constructor in this screenshot btw
『яє∂_ℓєgισn』
it says that myControl isnt in the context
**myControl**.Cursor = myCursor;
**myControl**.Cursor = myCursor;
i
Angius
Angius8mo ago
Well, yeah As I said, you should reference the control whose cursor you want to set
『яє∂_ℓєgισn』
okay ohhh i just realized what you meant okay so now the program wont open at all
many things
many things8mo ago
are there warnings in compilation?
Pobiega
Pobiega8mo ago
InitializeComponents is almost always called from the constructor, so you could find the constructor via the reference there
『яє∂_ℓєgισn』
no there is not

Did you find this page helpful?