**Developer**
In addition to Herfried's comments:
Cursor is a property of Control, Cursor is also a type that has a shared
property of Current
| C3.Cursor.Current = Cursors.WaitCursor
| C1.Cursor.Current = Cursors.WaitCursor
^ should be C2 shouldn't it?
| C1.Cursor.Current = Cursors.WaitCursor
In the above three lines you are setting the shared property
System.Windows.Forms.Cursor.Current to Cursors.WaitCursor, you are NOT
modifying any control's Cursor property!
This a change in 2005 or was it wrong in 2003 also??
If you used this code "as is" in VB2003, then yes your code was wrong in
VB2003 also!
FWIW: This is a very good example of why the warning was added!
To modify the Cursor property of a Control, you simply:
Dim C1 As Control
C1.Cursor = Cursors.WaitCursor
You don't need the pseudo recursion.
You can simplify your routine to:
Public Shared Sub SetToWaitCursor(ByVal c As Control)
' qualify the name to avoid attempting to use the Form/Control
property
System.Windows.Forms.Cursor.Current = Cursors.WaitCursor
End Sub
Which is effectively what you were running in VB 2003.
If you "need" the pseudo recursion, try:
For Each C1 As Control In c.Controls
For Each C2 As Control In C1.Controls
For Each C3 As Control In C2.Controls
C3.Cursor = Cursors.WaitCursor
Next C3
C2.Cursor = Cursors.WaitCursor
Next C2
C1.Cursor = Cursors.WaitCursor
Next C1
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
" **Developer**" <RE*************@a-znet.com> wrote in message
news:Op****************@TK2MSFTNGP09.phx.gbl...
| Not as simple as I thought.
|
| Many places where I set Cursor.Current I get the same message.
|
| Consider the following sub
|
| I get the error at each Cursor.Current
|
| Got any more wisdom to share?
|
|
|
|
|
| Public Shared Sub SetToWaitCursor(ByVal c As Control)
|
| 'This sub set Cursor.Current to Cursors.WaitCursor for all controls in
| c.Controls - searches 3 levels
|
| On Error Resume Next
|
| For Each C1 As Control In c.Controls
|
| For Each C2 As Control In C1.Controls
|
| For Each C3 As Control In C1.Controls
|
| C3.Cursor.Current = Cursors.WaitCursor
|
| Next C3
|
| C1.Cursor.Current = Cursors.WaitCursor
|
| Next C2
|
| C1.Cursor.Current = Cursors.WaitCursor
|
| Next C1
|
| End Sub
|
| "Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
| news:O8**************@TK2MSFTNGP09.phx.gbl...
| >" **Developer**" <RE*************@a-znet.com> schrieb:
| >> If e.Button = MouseButtons.Left Then
| >>
| >> also from a
| >>
| >> Dim Answer As DialogResult = MessageBox.Show..
| >>
| >> Select Case Answer
| >>
| >> Case DialogResult.Yes
| >>
| >> and many other uses of an enum I get
| >>
| >> Warning 153 Access of shared member, constant member, enum member or
| >> nested type through an instance; qualifying expression will not be
| >> evaluated.
| >
| > The problem is that forms have a 'DialogResult' property which shadows
the
| > type 'DialogResult'. Either fully qualify the 'DialogResult' type
| > ('System.Windows.Forms.DialogResult') or define a namespace alias:
| >
| > \\\
| > Imports WinForms = System.Windows.Forms
| > ...
| > If Answer = WinForms.DialogResult.OK Then
| > ...
| > End If
| > ///
| >
| > --
| > M S Herfried K. Wagner
| > M V P <URL:http://dotnet.mvps.org/>
| > V B <URL:http://classicvb.org/petition/>
|
|