This is a migrated thread and some comments may be shown as answers.

Changing Individual Items CSS styles

3 Answers 146 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Developer
Top achievements
Rank 1
Developer asked on 13 Jan 2009, 09:32 PM
Hello there, 

I have a radCombobox that holds phone types.  (business, cell, home etc)  When someone selects a type, it loads that phone number in a text box.  However, some types are blank, and some types hold a value.  I want to modify the css style of just the items that actually hold a value.

I have my combo box loading from a custom CSS sheet succesfully. 

When I modify these two classes in the CSS file, the changes are reflected in the drop down correctly.  However, I need to be able to change the styles from code behind.
.RadComboBoxDropDown_Outlook .rcbItem,  
.RadComboBoxDropDown_Outlook .rcbHovered,  
.RadComboBoxDropDown_Outlook .rcbDisabled,  
.RadComboBoxDropDown_Outlook .rcbLoading  
{  
    padding:1px 20px 1px 4px;  
}  
.RadComboBoxDropDown_Outlook .rcbHovered  
{  
    background:#306ac5;  
    color:#fff;  
I want to change the style when the item has value to something like this:
.RadComboBoxDropDown_Outlook2 .rcbItem,  
.RadComboBoxDropDown_Outlook2 .rcbHovered,  
.RadComboBoxDropDown_Outlook2 .rcbDisabled,  
.RadComboBoxDropDown_Outlook2 .rcbLoading  
{  
    padding:1px 4px 1px 20px;  
    color: Red;  
}  
.RadComboBoxDropDown_Outlook2 .rcbHovered  
{  
    background:red;  
    color:#fff;  

Here is where I tried to change the item in code behind but and was unsuccessful:
Dim typeArray() As Integer = .GetAllPhoneTypesAvailable()  
 
            For k As Integer = 0 To typeArray.Length - 1  
                rcbPhones.FindItemByValue(typeArray(k)).CssClass = "RadComboBoxDropDown_Outlook2" 
            Next 


any help is appreciated.

Coty

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Jan 2009, 08:05 AM
Hi Coty,

One suggestion to achieve this is by creating custom skin and set this skin for the RadComboBox. I hope the documentation link below will help you in creating the skin.
Tutorial: Creating a Custom Skin
CSS Skin File Selectors

Thanks,
Shinu.
0
Developer
Top achievements
Rank 1
answered on 14 Jan 2009, 03:38 PM
I have done that already.

I need the syntax of the code to dynamically change an items CSS classes in code behind.

I have found that doing this works:
radCombo.FindItemByValue(typeArray(k)).ForeColor = Drawing.Color.Black  
radCombo.FindItemByValue(typeArray(k)).BackColor = Drawing.Color.LightGreen 

But I was hoping to just modify the CSS style sheet.

Anyways, A side question....my form has 9 combo boxes (skins are all set the same) all of which have set enableembeddedskins="false" does the embedded skins create more overhead as you add more of the same conntrol?  I am guessing not but want to be sure.

thank you 
0
Yana
Telerik team
answered on 14 Jan 2009, 04:37 PM
Hello there,

There is no such problem with the embedded skins.

Kind regards,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Developer
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Developer
Top achievements
Rank 1
Yana
Telerik team
Share this question
or