Change Mouse Cursor in code???

stustarz

Junior Contributor
Joined
Jan 10, 2003
Messages
246
Location
Earth
Sorry if I may sound dull but in VB6 you said formname.mousecursor = vbWhatever - but how do you do this in vb.net?

I have tried msdn but it doesn't seem to tell me how to do it programatically only via the properties window.

Thanks again
 
Visual Basic:
Me.Cursor = Cursors.Hand
is one example. Use the intellisense after 'Cursors.' to pick one
of the cursors available.
 
Here's a helpful hint. When you want to change the cursor to an hourglass and make SURE you get it back before a function ends, use the following. It uses try/finally but doesn't really care about exceptions. It takes advantage of the fact that regardless of HOW you exit the try, the finally always runs.

Code:
try 
{
	this.Cursor = Cursors.WaitCursor;
	// Do something here, even call "return;"
}
finally
{
	this.Cursor = Cursors.Default;
}

-Nerseus

edited to put in [ code ] blocks
 
Last edited:
Back
Top