Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
469350
How can I override the AppStylist settings on a particular control?
posted

When you load an Application Style Library (isl) file into your application, the appstylist settings will override the appearances settings on any Infragistics controls in the application by default.

But suppose you want to override these settings on one or more individual controls? There are a number of ways you can achieve this.

ResolutionOrder

Within the Application Style Library, there is a setting which determines the order of precedence of appearances in the application. This setting is call ResolutionOrder and it is a property on the ComponentRole.

So you could open up your isl file in AppStylist and modify the ResolutionOrder under "Component Role Settings" on the "All Components" role (to affect all components) or on any individual component. By setting ResolutionOrder to ControlThenApplication, you will be given precedence to the appearances applied to a control in code. AppStylist settings will still be applied to the control, but only if no setting has been explicitly applied in the application source code.

Using "Based On"

Suppose you have an application that is using multiple instances of a certain control, such as the UltraGrid. Some of these controls will be used for one purpose and some for another, and so you want to apply different styling to different instances of the controls, but also have a certain base set of styling applied to all of the instances.

What you can do is create a StyleSet that contains only the styling that applies to all of the controls. Then create an additional StyleSet in your isl file that is "Based on" the base style and modify this StyleSet as needed.

Note that when one StyleSet is BasedOn another, the derived StyleSet will pick up all of the properties of the base StyleSet unless that property is overriden on the derived StyleSet. This means you cannot un-set a property on the derived styleset. For example, if you have a base styleset with a UIRole whose BackColor is set to Blue, you can set the derived StyleSet BackColor on the same UIRole to another color, but you cannot set it back to Default, because if the property is not set it will pick up the setting of the base StyleSet.

You apply the appropriate StyleSet to each control in your application using the StyleSetName property on the control.

UseAppStyling

Every Infragistics Winforms control has a property called UseAppStylist. When set to False, the control will ignore all AppStylist settings and only appearance applied in the source code will have any effect.

StyleLibraryName

Every Infragistics Winforms control has a property called StyleLibraryName. This property takes an arbitrary name of a StyleLibrary loaded into memory. Note that this is not necessarily the file name of the Application Style Library (isl) file. It can be any arbitrary string you choose.

When you call StyleManager.Load to load your isl file, you can optionally specify a name for your StyleLibrary in memory. This allows you to load more than one StyleLibrary into memory at the same time. And only controls whose StyleLibraryName matches the name you specified in the Load method will be affected.