Is there a base class where the following classes were derived that would have the "appearance" property:
Infragistics.Win.UltraWinGrid.UltraCombo
Infragistics.Win.UltraWinEditors.UltraTextEditor
Infragistics.Win.UltraWinMaskedEdit.UltraMaskedEdit
Infragistics.Win.UltraWinEditors.UltraNumericEditor
I'm trying to cast an object to the base class of these controls and then set the appearance.backcolor property as red
Thanks mike, I have a similar code to that right now.
By the way, if you just want to make all of your editors red, another option would be to use AppStylist. You could style all of your controls that way without writing any code, except one line of code to load the isl file.
Anyway, here's some sample code using reflection to set the Appearance property on a control, if such a property exists.
private void Form1_Load(object sender, EventArgs e) { Infragistics.Win.Appearance appearance = new Infragistics.Win.Appearance(); appearance.BackColor = Color.Red; foreach (Control control in this.Controls) SetAppearance(control, appearance); } private static void SetAppearance(Control control, Infragistics.Win.Appearance appearance) { PropertyDescriptorCollection props = TypeDescriptor.GetProperties(control); PropertyDescriptor appearanceProp = props.Find("Appearance", true); if (appearanceProp != null) { appearanceProp.SetValue(control, appearance); } }
Reflection can be ugly. You can also create your custom controls that inherit from IG controls and implement an interface that has the Appearance property.
Okay thanks. Can you provide a simple example on how to use reflection?
No, there's no common base class for these 4 controls that has the Appearance property.
If you know your application will have full trust, you could get the Appearance property via reflection. Otherwise, you will need to cast into the specific types.