C
C#2mo ago
Red Legion

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
Angius2mo ago
What have you tried and what doesn't work?
Red Legion
Red Legion2mo ago
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 …
Red Legion
Red Legion2mo ago
i bet it works i am just really confused on where to put the code snippets it puts there
Angius
Angius2mo 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
Red Legion
Red Legion2mo ago
okay
Angius
Angius2mo ago
So the code would probably go into the constructor of that main form
Red Legion
Red Legion2mo ago
so like this one?
No description
Angius
Angius2mo ago
ye
Red Legion
Red Legion2mo ago
okay
Red Legion
Red Legion2mo ago
would i just putr the code with myControl in this area then?
No description
Red Legion
Red Legion2mo ago
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
Angius2mo ago
In the constructor as well
Red Legion
Red Legion2mo ago
is the onstructer this part?
No description
Red Legion
Red Legion2mo ago
i am geussing it is\
Angius
Angius2mo ago
No
Red Legion
Red Legion2mo ago
oh where is the constructer
Angius
Angius2mo ago
$structure
MODiX
MODiX2mo 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
Angius2mo 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
Red Legion
Red Legion2mo ago
this part then?
No description
Red Legion
Red Legion2mo ago
i am really confused
Angius
Angius2mo ago
I guess InitializeComponent could work as well
Red Legion
Red Legion2mo ago
okay
Angius
Angius2mo ago
There is no constructor in this screenshot btw
Red Legion
Red Legion2mo ago
it says that myControl isnt in the context
**myControl**.Cursor = myCursor;
**myControl**.Cursor = myCursor;
i
Angius
Angius2mo ago
Well, yeah As I said, you should reference the control whose cursor you want to set
Red Legion
Red Legion2mo ago
okay ohhh i just realized what you meant okay so now the program wont open at all
Omnissiah
Omnissiah2mo ago
are there warnings in compilation?
Pobiega
Pobiega2mo ago
InitializeComponents is almost always called from the constructor, so you could find the constructor via the reference there
Red Legion
Red Legion2mo ago
no there is not
Want results from more Discord servers?
Add your server