Hi,
I would like to style the combobox dropdown in different colors (like windows do):
a) white background, when the combo is a comboeditor (dropdown)
b) grey background, when the combo is a combobox (dropdownlist)
How can I achieve this? Didn't get it work with AppStylist.
Different style resources exist, how can I apply this at runtime?
Hello Michael,
Thank you for your feedback.
If you need to style the dropdown of the combo you need to apply styling on the ValueList. Both ComboBoxTool of UltraToolbarsManager and UltraComboEditor expose ValueList property. So if you have ComboBoxTool you can use code above, or if you have UltraComboEditor you can use code like this:
this.ultraComboEditorDropDown.ValueList.Appearance.StyleLibraryName = "MyStyleLib";
this.ultraComboEditorDropDown.ValueList.Appearance.StyleResourceName = "DropDown";
this.ultraComboEditorDropDownList.ValueList.Appearance.StyleLibraryName = "MyStyleLib";
this.ultraComboEditorDropDownList.ValueList.Appearance.StyleResourceName = "DropDownList";
Please note you cannot set different StyleSet to ValueList but different style resources. You can apply different StyleSets per control, e.g you may have one UltraComboEditor with one StyleSet and another with other StyleSet but you may have only one StyleSet set to your UltraToolbarsManager.
Please check my updated sample where I have styled two UltraComboEditors’ ValueList the same way I did with ComboBoxTools.
Thank you for using Infragistics Controls.
any update on this?
Thanks for the quick answer and the example!
But I was looking for a way to change the StyleSet for the whole comboeditor control.
Like I do this for the normal comboeditor: The end result is an other background of the textarea of the comboeditor, not the valuelist.
I tried to find the right property, but it didn't work...
Here the code I use for the normal comboeditor
if (control is UltraComboEditor) {
if (editor.DropDownStyle == Infragistics.Win.DropDownStyle.DropDownList)
{ if (!editor.StyleSetName.Equals(_dropDownStyle, StringComparison.Ordinal)) { editor.StyleSetName = _dropDownStyle; } }
}
The whole bunch of appearance properties confuses me.
Thank you for posting in our forum.
You are on the right way. As long as you have created different style resources in your style library you need only to tell to each drop down which resource to use. You can achieve this by using code like this:
foreach (ToolBase tool in this.ultraToolbarsManager1.Tools)
{
// get all ComboBoxTool
var comboTool = tool as ComboBoxTool;
if (comboTool != null)
// set the style library to be used
comboTool.ValueList.Appearance.StyleLibraryName = "MyStyleLib";
// check the DropDownStyle and set accordingly the style resource
if (comboTool.DropDownStyle == DropDownStyle.DropDown)
comboTool.ValueList.Appearance.StyleResourceName = "DropDown";
if (comboTool.DropDownStyle == DropDownStyle.DropDownList)
comboTool.ValueList.Appearance.StyleResourceName = "DropDownList";
In the attached sample project I have implement this approach. Please check my sample and let me know if you need any additional information.