473,394 Members | 1,841 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,394 software developers and data experts.

VB 2008 - WaitCursor does not work

I am trying in Visual Basic 2008 to make the wait cursor appear as a file is opening, in case it is a long file, and this is the code, but it does not work:
Expand|Select|Wrap|Line Numbers
  1.         Dim openFile1 As New OpenFileDialog()
  2.             If DiscardChanges() Then
  3.                 Me.UseWaitCursor = True
  4.                 ' Initialize the OpenFileDialog to look for RTF files.
  5.                 openFile1.DefaultExt = "*.rtf"
  6.                 openFile1.Filter = "RTF Files|*.rtf|Doc Files|*.DOC|" & _
  7.                 "Text Files|*.txt|All Flies|*.*"
  8.                 ' Determine whether the user selected a file from the OpenFileDialog.
  9.                 If (openFile1.ShowDialog() = System.Windows.Forms.DialogResult.OK) _
  10.                     And (openFile1.FileName.Length > 0) Then
  11.                     ' Load the contents of the file into the RichTextBox.
  12.                     RichTextBox1.LoadFile(openFile1.FileName, _
  13.                         RichTextBoxStreamType.RichText)
  14.                     RichTextBox1.Modified = False
  15.                     fName = openFile1.FileName
  16.                 End If
  17.             End If
  18.             Me.UseWaitCursor = False
May 25 '09 #1
3 8157
Hi desertavataraz!

I'm a C# coder and I'm not sure about the whole UseWaitCursor-business, but how about this:

Add a line changing your current cursor to wait cursor just before doing the operation that might take long and changing it back to dafault after it's done.

Like this(example just sleeps 5 secs to simulate long file open):
Expand|Select|Wrap|Line Numbers
  1.         Me.Cursor = Cursors.WaitCursor
  2.         Threading.Thread.Sleep(5000)
  3.         Me.Cursor = Cursors.Default
If I were you, I'd place the cursor change to right before call to
Expand|Select|Wrap|Line Numbers
  1. RichTextBox1.LoadFile
and change it back right after it.

HTH,
salmenmikko
Jun 29 '09 #2
That looks like a very good suggestion, I will try it out when I get back from vacation . .. Thanks!
Jun 30 '09 #3
The UseWaitCursor applies to a specific control and all its child controls. This means that the cursor will change to a wait cursor when it is over that control or control group only. You would call it such ...

Expand|Select|Wrap|Line Numbers
  1. Me.UseWaitCursor = True
  2. Threading.Thread.Sleep(5000)
  3. Me.UseWaitCursor = False
It only works, however, when that control or control group is actually processing code. This means you can't just set the cursor and end code execution waiting for input from another source or control to clear the cursor. It may work that way if you set Application.UseWaitCursor = True, but then you may as well use the other code.
Jun 30 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: seash | last post by:
H i had set WaitCursor for some processing in my application, This works fine for my Windowsform, but i want to extend this wait cursor to all other programs i.e only waitcursor(hourglass) should...
2
by: Lenster | last post by:
I am trying to show an hourglass mouse cursor and disable the main form whilst waiting for some activity to finish. The problem I have come across is that as soon as you disable the main form the...
10
by: Just Me | last post by:
Does Me.Cursor.Current=Cursors.WaitCursor set the current property of Me.Cursor to Cursors.WaitCursor And Me.Cursor.Current=Cursors.Default set the Me.Current property to something (default)...
1
by: veerleverbr | last post by:
Hi, In my VB.NET code, at a certain moment I set the cursor to the hourglass: Cursor = System.Windows.Forms.Cursors.WaitCursor Then a lot of things happen in my form, but also in other...
6
by: Lars | last post by:
Hi, I have created a simple custom PrintPreviewDialog consisting of a simple standard PrintPreviewControl (.NET 1.1) on a WindowsForm with a few buttons (for printing, zooming, etc.). It is...
0
by: Netter | last post by:
I'm confused about: System.Windows.Forms.Cursor.Current = Cursors.WaitCursor Seems I read in this NG that it is not necessary to reset Cursor.Current because it gets reset automatically. Maybe...
1
by: =?Utf-8?B?bWdvbnphbGVzMw==?= | last post by:
I am unable to find the documentation on rotating the WaitCursor. ----- code --------- try { this.Cursor = Cursors.WaitCursor; // more code } catch
0
by: =?Utf-8?B?a20=?= | last post by:
I've got a simple C# app built in VS2005. When I click a menu item a modal form opens and performs a lengthy operation in the Load event handler to populate a text control, so it takes a few...
1
by: =?Utf-8?B?TWFuaXNoIEJhZm5h?= | last post by:
Hi, I have tried hard but not able to show waitcursor in betwen different processes.I launch new application from current application by using system.diagnostics.proceesstartinfo.Till second...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.