views:

566

answers:

3

We have a button which allows users to 'lock' a form. Users are not permitted to 'unlock' the form, so when pressed, we want the button to be disabled, so that the user receives appropriate visual feedback.

However, the customer reports that the greyed 'lock' icon suggests to them that the form is not locked, so we would like to display the button in a pressed state, but with the icon in colour, even though the button is disabled.

How do we do that, with the absolute minimum amount of overridden painting?

A: 

You can set the ToolStripButton Image as BackgroundImage
and then set the DiplayStyle to None.

The picture should stay in colour no matter what's the button Enabled value.

Tyalis
That doesn't quite work - for some reason the button doesn't respect ImageLayout.Center as a BackgroundImageLayout, so the image gets drawn in the top left corner.
Simon
You're right but if your picture has good ratio, you can use 'BackgroundImageLayout.Stretch' instead.
Tyalis
Hum ok I've just tried and the background image seems to disappear once the button become checked so it's still not a good answer sorry.
Tyalis
+1  A: 

Actually I disagree with the approach. Your customer might have a valid point, but I don't think they have the correct suggestion for the fix. You should look into other ways to make the form appear "locked". Changing borders or font colours, having a big padlock icon appear or change from open to closed etc. Buttons look a certain way because that's what users expect. If you have a disabled button that looks like it might be enabled, that's going to confuse users who might not then understand why they can't click it.

Neil Barnwell
I agree with you, but they're the ones who're paying.
Simon
A: 

Another way: don't set the button.Enabled = false at all. Just set the button.Checked = true or false and when someone clicks on the button test for the Checked state and do whatever you do. The button will then function as you want and stay colored too.

Frederick
Good point, but he did say that users can't unlock the form though, so that's not really what he's after.
Neil Barnwell
Yeah, if I leave button.Enabled as true, the user still gets visual feedback when they hover over the button, so it looks like they can click.
Simon