Under Windows Forms technology, I'm subclassing the Form class and overriding the OnControlAdded event invocator, my intention is that every control that is added to the control collection of my form, set its Control.BackColor
property to Color.Transparent
value regardless of the default color inheritance when a control is added into my Form.
However, as you probably know, some controls such as ListView
does not accept transparency and when attempting to set the Color.Transparent
value, a System.ArgumentException
will be thrown telling you can set transparent color.
Then, my question is:
In C# or VB.NET, which would be the proper way (maybe with Reflection, or maybe calling a Win32 function) to determine at runtime whether a control allows a transparent back color (Color.Transparent
)?... instead of handling the specified exception or classifying the control types in a switch
case, for example.