Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change cursor VB.NET

I can't change the cursor when it's a ToolStripButton.click event.

I got 2 buttons that call "Rechercher".

EDITED : Only the Button is working. It seems that the ToolStripButton cancel my cursor... Thx for the help

Public Class FenetrePrincipale

    Private WithEvents _btnRechercher As New Windows.Forms.ToolStripButton("Rechercher")
    Private WithEvents btnRechercherAccesBtn As New Button

    Private Sub Rechercher(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _btnRechercher.Click, btnRechercherAccesBtn.Click
        Try
            Me.Cursor = Cursors.WaitCursor
            'WAITING FOR THE CODE TO FINISH (2 sec)
        Finally
            Me.Cursor = Cursors.Default
        End Try
    End Sub
End Class
like image 809
Naster Avatar asked Feb 03 '12 19:02

Naster


People also ask

How do I change the cursor in Visual Basic?

Ensure your userform is showing in the Visual Basic Editor (keyboard shortcut Alt + F11) Ensure the Properties Pane is visible (keyboard shortcut F4) Select the userform you wish to modify. Within the Properties Pane, find the Property called MousePointer and change it to the fmMousePointerCustom option.

How do I change the cursor in Visual Studio?

For those on a Mac (running Windows+Visual Studio with either VMWare Fusion or Parallels, for example), press the 0 (zero) key in the Mac keyboard number pad. For me, this translates to the Insert key which changed the fat (overwrite) cursor back to the normal (insert) cursor.


1 Answers

Maybe you should try something sampler like:

Private Sub MainFrame_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  Search()
End Sub

Private Sub Search()
Try
  Me.Cursor = Cursors.WaitCursor
  UseWaitCursor = True
  Application.DoEvents()
  Threading.Thread.Sleep(1000) 'WAITING FOR THE CODE TO FINISH
Finally
   UseWaitCursor = False
   Me.Cursor = Cursors.Default
   Application.DoEvents()
End Try
End Sub

The problem is you don't have any pause where code should execute so it is doing to fast.

like image 191
FeRtoll Avatar answered Oct 27 '22 11:10

FeRtoll