You should handle things differently... there shouldn't be a reason to disable the form to prevent user interaction. Use a dialog box with a progress bar or a message that lets the user know what is going on. Don't give user an impression that the program is hanging or crashing. That is a horrible route to take. Think of a user perspective and what frustrated you when you use others' programs.
However, this worked for me:
this.Enabled = false;
this.UseWaitCursor = true;
Obviously, it only displays when cursor is over the form.
Here's the entire test code:
namespace WindowsFormsApplication1
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
this.button1.Location = new System.Drawing.Point(163, 110);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.Enabled = false;
this.UseWaitCursor = true;
}
private System.Windows.Forms.Button button1;
}
}