C# - Disable buttons with image
I'm using C# and WinForms.
When using a button with a BackgroundImage property, when I enable/disable the button, the image doesn't get gray... Result : The user is unable to tell if the button is enabled or disabled without trying to click it.
When using a button with a Image property, the image's behavior is correct but the image is not centered in the button !
As you can see in the picture, the first button uses BackgroundImage , the second o开发者_StackOverflow社区ne uses Image property but the minus sign is not centered properly... How can I manage this enable/disable state with a proper image's behavior ?
Thanks in advance !
I was doing the same thing some time ago and everything worked out by just using the Image property. You could try to set ImageAlign:
button.ImageAlign = System.Drawing.ContentAlignment.MiddleCenter;
Maybe increase the dimensions of the button to see if that changes anything (maybe the image is just too big for the disabled button. All I can tell you is that it should work perfectly using the Image property.
精彩评论