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 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.
Thank you for using Infragistics Controls.
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.
Hi Milko,
maybe I wasn't clear enough what I meant, but I attached a screenshot from the 'control panel->region->advanced' settings.
Here you see the difference of the combo-selection. White background for editable dropdown, greay background for non-editable dropdowns.
I am not able to set a style like this for the comboboxtool.
Maybe you can help again.
Michael
Thank you for your feedback.
So you need to style the combo edit area and not the dropdown area. To do so you need to add your resources to ToolBarEditArea UIRole in your style library and to set the style resource of the tool’ edit appearance. You may use code like this:
comboTool.EditAppearance.StyleLibraryName = "MyStyleLib";
comboTool.EditAppearance.StyleResourceName = "DropDown";
comboTool.EditAppearance.StyleResourceName = "DropDownList";
In the attached sample I have implemented this approach. Please check my sample and let me know if you need any additional information.
almost finished. Only the valuelist items should stay with white background.
But I think I can override the style for the valuelistitems (like you did before).
Better would be only to override the style of the textareacontrol of the comboboxtool.
The white background is the default appearance for value lists. So you only need to revert all the changes made to the value list. Firs you can remove the resources in style library and then remove the lines in code where stile library name and style resource name were set to the value list. Please check the attached sample project where I have removed any custom styling from the value list.
Thanks!
I was lost in all those style appearance/resources ;)