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