Change Background Color of Disabled DropDownList

4 posts, 0 answers
  1. Curtis
    Curtis avatar
    70 posts
    Member since:
    Oct 2014

    Posted 10 Aug 2018 Link to this post

    Hi Folks!

    I'm trying to override the template color of my DropDownLists so they don't stand out so poorly.

    I tried doing this:

    cmbNameSource.RootElement.SetThemeValueOverride(Telerik.WinControls.Primitives.FillPrimitive.BackColorProperty, Color.FromArgb(226, 226, 226), "Disabled", GetType(Primitives.FillPrimitive))

    But that didn't seem to have any effect...not to mention even if it did work, I still have to figure out how to change the forecolor of the Text that's displayed.

    Any help would be VERY appreciated!

    I'm attaching some png's so show you what I mean.  Every control in both images has .Enabled = False but as you can see the DropDownList's Look-n-Feel doesn't match the text boxes surrounding it.  That's what I'm trying to change!

    Thank you all very much :)

    -Curtis

     

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3903 posts

    Posted 13 Aug 2018 Link to this post

    Hello, Curtis,      

    RadDropDownList hosts the standard MS text box when the DropDownStyle property is set to RadDropDownStyle.DropDown. I supposed that you have already found the following article since the provided code follows a similar approach: https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/override-theme-settings-at-run-time

             this.radDropDownList1.DropDownListElement.SetThemeValueOverride(Telerik.WinControls.Primitives.FillPrimitive.BackColorProperty,
    Color.Red, "Disabled", typeof(Telerik.WinControls.Primitives.FillPrimitive));
             this.radDropDownList1.DropDownListElement.EditableElement.TextBox.SetThemeValueOverride(Telerik.WinControls.Primitives.FillPrimitive.BackColorProperty,
    Color.Red, "Disabled", typeof(Telerik.WinControls.Primitives.FillPrimitive));

    After I apply the following code snippet, the disabled state of RadDropDownList looks like the screenshot below:



    I hope this information helps. If you have any additional questions, please let me know.  
     
    Regards,
    Dess
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Curtis
    Curtis avatar
    70 posts
    Member since:
    Oct 2014

    Posted 13 Aug 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    You didn't say in your previous post if you'd selected a Theme for your control. Mine's been set to VisualStudio2012LightTheme

    I tried your code and I'm MUCH closer which is great progress but I still have an unsightly white border that you can see in the attached image.

    Here's the source for the test ap:

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    ' DropDownList1 has no Theme (or rather uses the Default)
    RadDropDownList1.DropDownListElement.SetThemeValueOverride(Telerik.WinControls.Primitives.FillPrimitive.BackColorProperty, Color.FromArgb(226, 226, 226), "Disabled", GetType(Telerik.WinControls.Primitives.FillPrimitive))
    RadDropDownList1.DropDownListElement.EditableElement.TextBox.SetThemeValueOverride(Telerik.WinControls.Primitives.FillPrimitive.BackColorProperty, Color.FromArgb(226, 226, 226), "Disabled", GetType(Telerik.WinControls.Primitives.FillPrimitive))

     

    ' DropDownList2 has VisualStudio2012LightTheme applied to it.
    RadDropDownList2.DropDownListElement.SetThemeValueOverride(Telerik.WinControls.Primitives.FillPrimitive.BackColorProperty, Color.FromArgb(226, 226, 226), "Disabled", GetType(Telerik.WinControls.Primitives.FillPrimitive))
    RadDropDownList2.DropDownListElement.EditableElement.TextBox.SetThemeValueOverride(Telerik.WinControls.Primitives.FillPrimitive.BackColorProperty, Color.FromArgb(226, 226, 226), "Disabled", GetType(Telerik.WinControls.Primitives.FillPrimitive))

    End Sub

    I can also see from your demo picture, you too have a 'light' border around your textbox (the color is 221, 231, 242)

    Is there any way to change that color as well?

     

    Thank you again for your help, Dess!

    -Curtis

     

     

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3903 posts

    Posted 15 Aug 2018 Link to this post

    Hello, Curtis,      

    For the VisualStudio2012Light theme you can use the following code snippet:

             this.radDropDownList1.DropDownListElement.SetThemeValueOverride(Telerik.WinControls.Primitives.FillPrimitive.BackColorProperty,
    Color.Red, "Disabled", typeof(Telerik.WinControls.Primitives.FillPrimitive));
     
               this.radDropDownList1.DropDownListElement.EditableElement.SetThemeValueOverride(Telerik.WinControls.Primitives.FillPrimitive.BackColorProperty,
    Color.Red, "Disabled" );
     
     
             this.radDropDownList1.DropDownListElement.EditableElement.TextBox.SetThemeValueOverride(Telerik.WinControls.Primitives.FillPrimitive.BackColorProperty,
    Color.Red, "Disabled", typeof(Telerik.WinControls.Primitives.FillPrimitive));



    I hope this information helps. If you have any additional questions, please let me know.  
     
    Regards,
    Dess
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top