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

Set DisabledStyle in Code Behind

1 Answer 60 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Darren
Top achievements
Rank 1
Darren asked on 13 Mar 2013, 03:32 PM
How do you set the DisabledStyle for a ComboBox in Code Behind?

I tried this but it didn't work:
[ToolboxData("<{0}:RadComboBoxEx runat='server'></{0}:RadComboBoxEx>")]
public class RadComboBoxEx : RadComboBox
{
    public RadComboBoxEx()
        : base()
    {
        //this.DisabledStyle.BackColor = System.Drawing.Color.White;
        //this.DisabledStyle.ForeColor = System.Drawing.Color.LightGray;
        this.Init += new EventHandler(RadComboBoxEx_Init);
    }
 
    void RadComboBoxEx_Init(object sender, EventArgs e)
    {
        SetDisabledStyle(this.Controls);
    }
 
    private void SetDisabledStyle(ControlCollection controlCollection)
    {
        foreach(Control control in controlCollection)
        {
            if ( control is RadInputControl )
            {
                RadInputControl input = (RadInputControl)control;
 
                input.DisabledStyle.BackColor = System.Drawing.Color.White;
                input.DisabledStyle.ForeColor = System.Drawing.Color.LightGray;
            }
            else
            {
                SetDisabledStyle(control.Controls);
            }
        }
    }

1 Answer, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 15 Mar 2013, 03:47 PM
Hello Darren,

I can suggest you to apply the disabled style of the RadComboBox in the following manner :

RadComboBox1.InputCssClass = "rcbReadOnly";


Kind regards,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ComboBox
Asked by
Darren
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Share this question
or