Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change mousepointer in Windows forms to an hourglass? 1

Status
Not open for further replies.

dlombardi

Programmer
Dec 6, 2002
2
US
I am trying to do something simple like change the mousepointer to an hourglass then back to an arrow at the end of a function. I'm using VB.NET
 
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
 
This will change the cursor for the backform but not the controls. If you move the mouse over a button or textbox the pointer will turn back

Try

Cursor.Current = Cursors.WaitCursor

But this also changes back if you alt and tab to another application.

Not sure what is the correct way

Matt
 

Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
Dim i As Integer
Do Until i = Me.Controls.Count
Me.Controls(i).Cursor = System.Windows.Forms.Cursors.WaitCursor
i = i + 1
Loop
 
Surely that is a little intensive on resources especially if you have a lot of controls on the form.

But it'll do for me.

Ta
 
Intensive? Even at 1000 controls, I don't think it is very intesive to change the properties of them. Probably much less intensive than loading up the form initially with all the controls.
 
This may help you........

I was using a datagrid and wanted the hand cursor to show up whenever I moved it up and down the rows displayed in my datagrid. I used the mousemove event of the datagrid to change my cursor like this...
"me.datagrid1.cursor = cursors.hand"

This would work only when I first entered the grid but as soon as I moved it up or down a row it would go back to the default cursor. I resolved this by putting both..

"me.datagrid1.cursor = cursors.hand"
"me.cursor = cursors.hand"

in the mousemove event and then created the mouseleave event of the datagrid to return the cursor to the default. This resolved the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top