We have a control which adds 2 buttons to a combobox. Works splendid.
Now, when we disable the combobox we have to set the DisabledBackColor and DisabledForeColor to Black and White. Works also very good...
BUT the background of the 2 buttons are after disabling grey. See attachment.
Is there anyway we can set this background to white or maybe make the buttons invisible ?
The combo is disabled AFTER the combo is initialized so I cannot make the buttons invisible when I add them to the combo...
BackColorDisabled and ForeColorDisabled do not work here because I added a picture to the button instead of text.
I solved the problem using the EnabledChanged event as you told me. I also had to remove the button when the control was set read-only instead of Enabled. I fixed that using the PropertyChanged event.
Case closed. Thanks for the help :-)
Hi,
Just like the Combo, the buttons in the ButtonsRight collection have an appearance (which is how you are getting your image in there). So you could do the same thing you are doing for the combo - set a DisabledBackcolor and DisabledForeColor on each button.
There is no way to hide a button in the ButtonsRight collection. But you could handle the EnabledChanged event of the combo and remove those buttons when the control is disabled and then re-add them when it is enabled.
Another option would be to use a CreationFilter to remove the UIElements for those buttons, but this would be a bit more complex, especially if you are not familiar with CreationFilters.