By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,453 Members | 3,225 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,453 IT Pros & Developers. It's quick & easy.

cursor question

P: n/a
In my form Ive got a SaveData() routine that saves changes to a DB.
When I encounter an exception in the save operations, I am having
trouble chaning the cursor back to the default cursor, it just stays
as an hourglass. It seems as though the cursor can only be set in the
context of the form. I would like to set the cursor within my
standard error handling module. See code below...
Any ideas?

Thanks,
Dave

---------------
SaveData()
Try
Me.Cursor = Cursors.WaitCursor
...
SaveToDB....
...
Me.Cursor = Cursors.Default

Catch
DisplayErrorMessage(...)
End Try
End Sub
---------------
DisplayErrorMessage(...)
Try
...
MessageBox.Show(...)
...
Catch
MessageBox.Show("Something really bad happened")
Finally
Cursor.Current = Cursors.Default
...
End Try
End Sub
------------------
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Dave,

I think you are better off changing the cursor back in a Finally block of
the routine in the form. First off it will work but beyond that, the form
is where you changed the cursor to begin with. This gives the code
symmetry and it means that (rather than setting the cursor to "Default" you
can save the cursor setting and restore it to whatever it was. Yes that
will typically be .Default but if it wasn't you will restore it correctly in
any case.

Tom

"dave" <th*****@mailcity.com> wrote...
I would like to set the cursor within my
standard error handling module.

Nov 20 '05 #2

P: n/a
Dave,
You are changing two totally different cursor variables!

Here your setting the current Form's Cursor.
Me.Cursor = Cursors.WaitCursor
Here you are setting the "global" cursor variable Cursor.Current = Cursors.Default
The Current form's cursor will still have been modified. Remember each form
has its own Cursor property that allows distinct cursors per form (the I bar
for text boxes, the cross hairs for drawing, the Arrow for dialog boxes).

I would suggest you either set just the Form's cursor or just the "global"
cursor. However, remember you do not need to reset the "global" cursor (back
to Cursors.Default), as the Framework will automatically change it back to
Cursors.Default when it has finished processing the current event (or you
call DoEvents).

I normally only modify Cursor.Current to Cursors.WaitCursor as I don't
normally call DoEvents, this allows the cursor to revert to Cursors.Default
automatically for me (when the current event is done processing). I normally
only change Me.Cursor when I need to cursor for that form to change, such as
cross hairs or sizing pointer...

Hope this helps
Jay

"dave" <th*****@mailcity.com> wrote in message
news:f9**************************@posting.google.c om... In my form Ive got a SaveData() routine that saves changes to a DB.
When I encounter an exception in the save operations, I am having
trouble chaning the cursor back to the default cursor, it just stays
as an hourglass. It seems as though the cursor can only be set in the
context of the form. I would like to set the cursor within my
standard error handling module. See code below...
Any ideas?

Thanks,
Dave

---------------
SaveData()
Try
Me.Cursor = Cursors.WaitCursor
...
SaveToDB....
...
Me.Cursor = Cursors.Default

Catch
DisplayErrorMessage(...)
End Try
End Sub
---------------
DisplayErrorMessage(...)
Try
...
MessageBox.Show(...)
...
Catch
MessageBox.Show("Something really bad happened")
Finally
Cursor.Current = Cursors.Default
...
End Try
End Sub
------------------

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.