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

3 posts, 0 answers
  1. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 03 May 2011 Link to this post

    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. Alcide Burato
    Alcide Burato avatar
    14 posts
    Member since:
    Mar 2011

    Posted 03 May 2011 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 03 May 2011 Link to this post

    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
Back to Top