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

Change Background Color of Disabled DropDownList

3 Answers 871 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
Curtis asked on 10 Aug 2018, 06:18 AM

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

 

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Aug 2018, 08:51 AM
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.
0
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 13 Aug 2018, 11:20 PM

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

 

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Aug 2018, 10:20 AM
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.
Tags
DropDownList
Asked by
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or