I know this is an old branch, but accidentally discovered an alternative simple solution.
Create a new transparent label control that inherits from the label:
class TransparentLabel : Label { public TransparentLabel() { this.SetStyle(ControlStyles.Opaque, true); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false); } protected override CreateParams CreateParams { get { CreateParams parms = base.CreateParams; parms.ExStyle |= 0x20;
(I do not claim to have invented this class, it came from somewhere else, probably Hans Passant :-))
In your designer, create a TransparentLabel and give it a name, say tLabel1 . Set the properties as follows:
AutoSize is False so you can then expand it to cover all the controls you want to disable (of course, this could be a whole form).Text is empty.Visible - False (or leave it true if you want to see it in the constructor, in this case move it to the end of the Z-sequence so that you can also see the controls that it will cover when the form starts).
In the form, execute this bit of code if you want to disable controls:
tLabel1.Visible = true; tLabel1.BringToFront();
This works because when it is visible, TransparentLabel receives all mouse clicks and keystrokes, not the basic control, but it is transparent, so you still see the basic controls. Right-clicking does nothing because shortcuts do not have a context menu.
To enable the controls again, simply set the Visible property to false again and everything will come back to life.
Jonp source share