I do not want to use themes at all.
I found some sample code and it works with all colors except for SystemColors.Control.
To prove this I just blended the Control backcolor slightly and it works correctly then.
This is not a critical issue as I have found a work around but this is quite tricky to do a took me like about an hour to figure it out,
Changing a controls back color is something that should be simple.
I was expecting to turn the EnableTheming = False and then just be able to change a textbox.Backcolor property and that is all.
But I would be happy to have this SystemColors.Control issue fixed.
Here is some sample code I have made to show the issue,
I'm using a wrapper class so i can add controls the way i want them to behave with out setting lots of individual properties everytime.
Public Class RadMaskedEditBoxX
Inherits Telerik.WinControls.UI.RadMaskedEditBox
Public Sub New()
Me.EnableTheming = False
End Sub
Protected Overrides Sub OnReadOnlyChanged(ByVal e As System.EventArgs)
MyBase.OnReadOnlyChanged(e)
If Me.ReadOnly Then
SetColor(SystemColors.Control)
Else
SetColor(SystemColors.Window)
End If
End Sub
Public Sub SetColor(ByVal clrColor As Color)
MyBase.MaskedEditBoxElement.Fill.GradientStyle = Telerik.WinControls.GradientStyles.Solid
MyBase.MaskedEditBoxElement.Fill.BackColor = clrColor
MyBase.MaskedEditBoxElement.Border.ForeColor = SystemColors.WindowFrame
'--------------------------------------------------------------------
' This Line does not work correctly with the Control Color, it does with any other color.
' When set to Control it still blends itself with white so is some light grey color
'(very hard to tell difference from white (non-readonly) textbox).
MyBase.MaskedEditBoxElement.BackColor = SystemColors.Control
' -------------------------------------------------------------------
' This is my fix for this problem, To blend the color so it is not = SystemColors.Control but very close
'MyBase.MaskedEditBoxElement.BackColor = modShared.BlendColor(SystemColors.Control, Color.White, 1)
End Sub
Public Overrides Property ThemeClassName() As String
Get
Return GetType(Telerik.WinControls.UI.RadMaskedEditBox).FullName
End Get
Set(ByVal value As String)
MyBase.ThemeClassName = value
End Set
End Property
Public Function BlendColor(ByVal p_Color1 As Color, ByVal p_Color2 As Color, ByVal p_blend As Integer) As Color
Try
Dim r As Single, g As Single, b As Single
Dim dr As Single, dg As Single, db As Single
dr = (p_Color2.R - p_Color1.R) / 255
dg = (p_Color2.G - p_Color1.G) / 255
db = (p_Color2.B - p_Color1.B) / 255
r = p_Color1.R
g = p_Color1.G
b = p_Color1.B
BlendColor = Color.FromArgb(r + (dr * p_blend), g + (dg * p_blend), b + (db * p_blend))
Catch
Try
Dim r As Single, g As Single, b As Single
Dim dr As Single, dg As Single, db As Single
dr = (p_Color1.R - p_Color2.R) / 255
dg = (p_Color1.G - p_Color2.G) / 255
db = (p_Color1.B - p_Color2.B) / 255
r = p_Color2.R
g = p_Color2.G
b = p_Color2.B
BlendColor = Color.FromArgb(r + (dr * p_blend), g + (dg * p_blend), b + (db * p_blend))
Catch
If p_blend < 127 Then
BlendColor = p_Color1
Else
BlendColor = p_Color2
End If
End Try
End Try
End Function
End Class