Reputation: 957
I would like to disable
the whole Form
but still, keep each of this Form
elements like TextBox, Buttons etc to look like enabled
.
So, I want to block user interactions on those elements, but preserve it's standard look, not grayed out etc.
Can that be done in kind of automatic way or one just need to manually handle EnabledChanged
events for each of affected controls?
Upvotes: 0
Views: 250
Reputation: 11357
The easiest solution would be to have a transparent image on top of all controls and you just show it when you want to disable the controls.
This image will catch all mouse inputs but it is possible that the controls can still be selected by keyboard.
Upvotes: 0
Reputation: 3751
For all the controls, the "backcolor" property is set to window by default. Select all of them and set to white (or the desired color) to get the same appearance. You might want to do the same with text and border color. Its all about the level of customization you want.
To have complete control over the colors, you will need to redraw them.
protected override void OnPaint ( System.Windows.Forms.PaintEventArgs e )
{
if ( Enabled )
{
//use normal realization
base.OnPaint (e);
return;
}
//custom drawing
using ( Brush aBrush = new SolidBrush( "YourCustomDisableColor" ) )
{
e.Graphics.DrawString( Text, Font, aBrush, ClientRectangle );
}
}
Upvotes: 1