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
910
Apply different ComboboxStyle on ComboboxTool from different state: DropDownList vs. DropDown
posted

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?

Parents
No Data
Reply
  • 21795
    Offline posted

    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.

    CAS-168421-L4W2R6.zip
Children