Current Cursor Question

E

Erik Jensen

Hi, in my main application class i'm able to write

Cursor.Current = Cursors.WaitCursor;

However, in a different class I have to write:

this.Cursor = Cursors.WaitCursor;

it says Ambiguous reference when I try and write it the
first way.

Can anyone shed some light on this for me?

thanks
 
W

Wim Hollebrandse

Because the control classes have a Cursor property. If you refer to Cursor
inside you control class - there's an ambiguous meaning. You either mean to
call a static property on the Cursor class or try to set the Cursor property
for your control.

What you want to do in the first statement is set the static property
Current on the Cursor class - which will apply, regardless of which Control
has the focus.

In order to avoid this you could use namespace aliasing, or simply specify
the full namespace path:

System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;

HTH,
Wim Hollebrandse
http://www.wimdows.com
http://www.wimdows.net
 

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