Hide cursor on my form
c#, winforms
Solution
It is suggested to use `Cursor.Hide();` in the form constructor.
Applying this to the form itself doesn't work
I dont think you'll ever have to care about cursor when you move out of your Application's territory.The very time the form initializes put the code there.
public Form1()
{
InitializeComponent();
Cursor.Hide();
}
One more recommended way is to iterate through control collection i.e.
foreach(Control c in this.Controls)
{
c.Cursor.Hide();
}
Problem
I need help on how to hide the cursor when the mouse is over one of my application forms. I know the code is Cursor.Hide() and Cursor.Show() for the MouseEnter and MouseLeave events respectively. Applying this to the form itself doesn't work. So I inserted a panel (set its Dock property to Fill) to contain the other controls. The code worked for the panel but when I started adding controls, it didn't. My guess is that I have to apply the code to each control. With about 25 controls on my form, that seems rather clumsy. My idea was this (I'm sorry for the formatting; I'm typing this from a dumbphone): ``` foreach(Control control in this.Controls) { control.MouseEnter += control_MouseEnter; control.MouseLeave += control_MouseLeave; } ``` The code was inside FrmScreen_Load. But it still doesn't work. Am I missing something? I'm working in C# but solutions in VB.NET are acceptable.