473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

cursor question

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
2 1760
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ed | last post by:
Hello, I posted a question about looping with Select in a While loop, a few days ago. Repliers to my post advised me that a Cursor would be much better (thanks all for your replies). I found...
3
by: DarthMacgyver | last post by:
Hello, I recently wrote a survey application. Each question is very similar. The first questions gives me a problem when there are multiple people taking the survey (The Database connection...
1
by: David Battams | last post by:
Ok, this is possibly the dumbest question ever asked on a MS.Net forum, but I cannot for the life of me work out how to enable the set hotspot button to set a cursor hotspot in .Net 2002 or 2003....
3
by: Simon Wigzell | last post by:
I have an image with several links in it in mapped areas. I am using a custom cursor on the page and would like to have a custom cursor appear on mouse over of the mapped links. Something like: ...
2
by: Just Me | last post by:
I have a usercontrol, UC1, which contains a different usercontrol, UC2, a listview and a combobox. In the code for UC1 I do: Cursor = Cursors.WaitCursor The mousepointer changes to the...
6
by: Peter Oliphant | last post by:
I've now asked how three times in this forum with no answers. So I went to the 'windowsforms' newsgroup, and found this post, also unanswered, with the same problem: "Hello, I've tried to...
7
by: P. Adhia | last post by:
Sorry for quoting an old post and probably I am reading out of context so my concern is unfounded. But I would appreciate if I can get someone or Serge to confirm. Also unlike the question asked in...
13
by: WALDO | last post by:
I have a .Net TextBox (TextBoxBase, really) in which I am appending about 20 lines of text per second. I use the AppendText() method to accomplish this. This is a great substitute for taking the...
10
by: Franky | last post by:
I think I misread a post and understood that if I do: System.Windows.Forms.Cursor.Current = Cursors.WaitCursor there is no need to reset the cursor to Default. So I made all the reset...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.