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