Mouse Pointer not changing (C#)

R

R-D-C

Hi,

I have a process that takes a good ten seconds and want to show an hourglass
mouse pointer.

I am using:

this.Cursor = Cursors.WaitCursor;
Application.DoEvents();

// Long thing

this.Cursor = Cursors.Default;


.... when I run this, the pointer does not change shape until after the long
thing at which point I want it to change back :(

Can anybody help please?
 
R

R-D-C

More Info:

The call is made as a drop-down list box value changes. If I change the
list value with the mouse, the pointer doesn't change shape. If, however, I
update the value by scrolling up and down with the cursor keys on the
keyboard, the mouse pointer DOES change correctly!

Please help.
 
R

R-D-C

OK, final bit of info:

Just below the drop-down list is a textbox which happens to be underneath
the option in the drop-down that takes the most time. When I move the
textbox lower on the screen, the mouse pointer changes shape as I want it
to.

AAAAAAGGGGHHHHHH!!!!!!!!
 
R

R-D-C

And now the solution.

The underlying textbox had a cursor set to IBeam by default. This means
that you specifically have to set the cursor for all textboxes as they will
not default to their parent's pointer.

If you apply the Default pointer type to a textbox this shows an arrow, not
an IBeam as I would have expected.

I think .NET user interface functionality was sent by Microsoft to try us...
 
J

Joe White

That's because you were setting the form's Cursor. That will only cascade
down to child controls that don't specify their own Cursor. This is
designed behavior.

Try setting Cursor.Current instead of this.Cursor. It should do what you
want, and you won't have to change anything on your text boxes.
 
R

R-D-C

Nope, same effect

:(


Joe White said:
That's because you were setting the form's Cursor. That will only cascade
down to child controls that don't specify their own Cursor. This is
designed behavior.

Try setting Cursor.Current instead of this.Cursor. It should do what you
want, and you won't have to change anything on your text boxes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top