When I am loading the isl file at runtime as shown in the samples, the style is loaded on whole application. Is there a way to apply it only on one form or a few forms.
Hello Bharat,
When loading AppStyle, you could apply it to all Infragistics controls into your application or only to specific IG controls. Also you are able to load more than one AppStyle and after that you could choose which AppStyle to be used from each of IG controls.
Bharat Jangir said:Is there a way to apply it only on one form or a few forms
Let me know if you have any questions.
Hi Georgi,
In my application some forms are made from IG controls and some are IG controls + windows controls(mixed). So I want to apply AppStyle with some specific forms (forms that only made from IG controls).
Thanks
Bharat
Hi Bharat,
There's no way to limit the AppStyling to a single form, but you can limit it to the controls themselves.
What you do is... when you call StyleManager.Load, you use the overload that takes in a name. You can specify any arbitrary string for the name and what that means is the the style library will only apply to controls whose StyleLibraryName property it set to the same string. So then you have to go to your form and set StyleLibraryName to the same string for any controls that you want to pick up the styling.
Thanks Mike, I would also like to mention a workaround which we used.
If we load all the style libraries with some alias name then the style libraries are not loaded to any control where the property StyleLibraryName is not set .
So we are now only assigning the property on the forms where we want it to load the library.
Hi,
If you need any additional assistance don’t hesitate to ask.
Regards
Yes, nothing related to this had changed in the intervening years.
HI,
I see that the above method that you described was posted in 2013.
Is this still how you would recommend setting the stylesets problematically?
Well... it's possible that this might miss some controls that are not directly on the form. Floating windows and dialogs and things like that.
It's also possible that there are some controls that support AppStylist but do not derive from UltraControlBase. And this does not account for any components on the form that would not be included in the Controls collection.
Can you explain why this would not be 100% effective?
I could see where there would be an issue if you have windows controls mixed up with Infragistics controls.
Are the any other issues that you are referring to?
Hi Puneet,
It's not 100% effective, but you can use 'UltraControlBase'. Here's a static method I use to handle this for StyleLibraryName, but you could easily just change StyleLibraryName to StyleSetname:
internal static void SetStyleLibraryName(Control control, string styleLibraryName) { UltraControlBase ultraControlBase = control as UltraControlBase; if (ultraControlBase != null) { ultraControlBase.StyleLibraryName = styleLibraryName; } UltraToolbarsDockArea ultraToolbarsDockArea = control as UltraToolbarsDockArea; if (ultraToolbarsDockArea != null) { UltraToolbarsManager ultraToolbarsManager = ultraToolbarsDockArea.ToolbarsManager; ultraToolbarsManager.StyleLibraryName = styleLibraryName; } foreach (Control childControl in control.Controls) { SetStyleLibraryName(childControl, styleLibraryName); } }