Hello,
I maintain an application used by two different companies who each want their own icon on the control bar of dialogs.
Currently the icon is set using the InboxControlStyler.
What I would like to do is set the icon at runtime (I have set resource and role colors at runtime) when the application starts but can't seem to work out how.
Any help greatly appreciated,Paul
Hi Paul,
There's not much information here to go on.
What control is displaying the icon?
What does the InboxControlStyle have to do with it?
Hi Mike,
Thanks for responding.
The Component I'm setting the icon for is the Inbox Form.
The InboxControlStyler is used to set the icon currently as I've set the Icon property in Inbox Form-specific properies in the AppStylist library.
The question is how do I set the Icon property in Component Role Settings->Inbox Components->Inbox Form Component at runtime?
Thanks,Paul
Okay. Whatever works for you.
But my way would have been a lot easier and a lot less code. :)
Thanks for the suggestion Mike but I've worked out how to change the icon at runtime.
The code is as follows:
public static void SetIcon(string componentName, Icon formIcon) { ApplicationStyleLibrary styleLibrary = new ApplicationStyleLibrary(); styleLibrary.LoadFromStyleManager(); StyleSetSettings styleSet = null; if (styleLibrary.StyleSets.Count > 0 && styleLibrary.DefaultStyleSet != null) styleSet = styleLibrary.StyleSets[styleLibrary.DefaultStyleSet]; if (styleSet == null) { styleSet = styleLibrary.StyleSets.Add("Default"); styleLibrary.DefaultStyleSet = styleSet.Key; } ComponentStyleSettings comp = styleSet.ComponentStyles.GetComponentStyle(componentName, true); comp.CustomProperties["Icon"] = formIcon; styleLibrary.UpdateStyleManager(); }
To call the method
SetIcon("Inbox Form", icon);
Oh, that icon. :)
Well... the easiest thing to do would be to remove the icon setting from the ApplicationStyleLibrary (isl) file. The isl will make every effort to override your run-time setting. So it will be a lot easier to set the icon of the form at run-time if the isl file is NOT setting it at all. Then it's just a matter of setting the Icon property of the form.