Can"t change to WaitCursor when showing a modal dialog

Can"t change to WaitCursor when showing a modal dialog

am 01.02.2008 19:10:02 von km

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 seconds before the modal form is
actually displayed. I would like to change the cursor to the WaitCursor
between the time that the menu item is clicked and the modal form is actually
visible.

I've tried setting the form's cursor in the Load event handler:

private void OnFormLoad(object sender,EventArgs e)
{
Cursor oOldCursor=this.Cursor;
this.Cursor = Cursors.WaitCursor;
Application.DoEvents();
try
{
...
}
finally
{
this.Cursor = m_oOldCursor;
}
}

Sometimes the cursor changes, sometimes not, sometimes it just flashes
briefly. I've also tried using Application.UseWaitCursor, Cursor.Current, to
no effect. I've also tried all these in the main form before showing the
modal form. For example:

// in the main form
Cursor.Current = Cursors.WaitCursor;
MyForm frm=new MyForm();
frm.ShowDialog(this);

Any suggestions on how to get this to work?