Suppose for each form in a WinForms application you want to change the cursor to WaitCursor. The obvious way to do this is to add code to any place where the form is created or displayed:
Try
Me.Cursor = Cursors.WaitCursor
Dim f As New frmMyForm
f.Show()
Catch ex As Exception
Throw
Finally
Me.Cursor = Cursors.Default
End Try
However, I was wondering if there is a way to tell your application: "Whenever some form of Load event fires, show WaitCursor. When the event of the Shown form is completed, set the cursor to the default value." Thus, the Me.Cursor code can only be in one place and is not scattered throughout the application - and do not forget to put it in each instance of the form.
I assume that you can subclass the regular Form class and add cursor settings to the overridden event, but I believe that you will lose the visual designer’s ability when subclassing the Form object.
source
share