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

A problem applying custom theme to a disabled RadDropDownList (Thread vanished)

2 Answers 112 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Emanuel Varga
Top achievements
Rank 1
Emanuel Varga asked on 03 May 2011, 08:53 AM
Hello again,

**** THIS IS A RESPONSE TO A PREVIOUSLY CREATED THREAD ****

Apparently the thread vanished...

Anyway you could always create a custom control, something like this, so you could pass all the extra logic there, including but not limited to themes and other info..

public class CustomDropDownList : UserControl
{
    private RadDropDownList dropDownList;
 
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public RadDropDownList DropDownList
    {
        get
        {
            return dropDownList;
        }
    }
 
    public CustomDropDownList()
    {
        dropDownList = new RadDropDownList();
        dropDownList.Dock = DockStyle.Fill;
        this.Controls.Add(dropDownList);
        this.Size = new Size(dropDownList.PreferredSize.Width, dropDownList.PreferredSize.Height + 1);
 
    }
 
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        if (!dropDownList.Enabled || !this.Enabled)
        {
            this.Enabled = true;
            dropDownList.Enabled = true;
            dropDownList.Enabled = false;
            this.Enabled = false;
        }
    }
 
    protected override void Dispose(bool disposing)
    {
        base.Dispose(disposing);
 
        if (dropDownList != null)
        {
            dropDownList.Dispose();
            dropDownList = null;
        }
    }
}

(The screenshots below are for the thread disappearance itself)

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga

Telerik WinForms MVP

2 Answers, 1 is accepted

Sort by
0
Alcide Burato
Top achievements
Rank 1
answered on 03 May 2011, 11:55 AM
Hello Emanuel,

Don't worry about the vanished thread.

I have follow your suggestion, but instead of creating a new user control, I have inherits directly from RadDropDownList with a little modification of the OnLoad method. I confirm you it works and solve the problem in an easy way.

public class ExtendedComboBox : RadDropDownList
{
    public ExtendedComboBox()
    {
        InitializeComponent();
        ThemeName = "ExampleTheme";
        ThemeClassName = "Telerik.WinControls.UI.RadDropDownList";
    }
 
    protected override void OnLoad(Size s)
    {
        base.OnLoad(s);
        if (!this.Enabled)
        {
            this.Enabled = true;
            this.Enabled = false;
        }
    }
}

Thanks again.

Regards,
Alcide
0
Emanuel Varga
Top achievements
Rank 1
answered on 03 May 2011, 12:20 PM
Hello again Alcide,

Be careful, that OnLoad(Size) is different than the UserControl's OnLoad(EventArgs).

Other than that, glad to be able to help.

Best Regards,
Emanuel Varga

Telerik WinForms MVP
Tags
DropDownList
Asked by
Emanuel Varga
Top achievements
Rank 1
Answers by
Alcide Burato
Top achievements
Rank 1
Emanuel Varga
Top achievements
Rank 1
Share this question
or