C
Claudio111
Guest
Hi All
I'm trying to change a DateTimePicker backcolor using a code I found on forums
Imports System.Windows.Forms
Imports System.Drawing
Imports System.ComponentModel
Namespace DateTimePickerWithBackColor
Public Class MyDateTimePicker
Inherits DateTimePicker
<Browsable(True)>
Public Overrides Property BackColor() As Color
Get
Return MyBase.BackColor
End Get
Set
MyBase.BackColor = Value
End Set
End Property
Protected Overrides Sub WndProc(ByRef m As Message)
Dim WM_ERASEBKGND As Integer = &H14
If (m.Msg = WM_ERASEBKGND) Then
Dim g As Graphics = Graphics.FromHdc(m.WParam)
g.FillRectangle(New SolidBrush(BackColor), ClientRectangle)
g.Dispose()
Return
End If
MyBase.WndProc(m)
End Sub
End Class
End Namespace
I use in a simple winform where there is a Button and the MyDatePickerControl
Nothing else
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
DateTimePicker1.BackColor = Color.Yellow
DateTimePicker1.Invalidate()
End Sub
When I click on the button the DateTimePicker back color do not change and I spent hours to understand why
Can you help Me ?
Continue reading...
I'm trying to change a DateTimePicker backcolor using a code I found on forums
Imports System.Windows.Forms
Imports System.Drawing
Imports System.ComponentModel
Namespace DateTimePickerWithBackColor
Public Class MyDateTimePicker
Inherits DateTimePicker
<Browsable(True)>
Public Overrides Property BackColor() As Color
Get
Return MyBase.BackColor
End Get
Set
MyBase.BackColor = Value
End Set
End Property
Protected Overrides Sub WndProc(ByRef m As Message)
Dim WM_ERASEBKGND As Integer = &H14
If (m.Msg = WM_ERASEBKGND) Then
Dim g As Graphics = Graphics.FromHdc(m.WParam)
g.FillRectangle(New SolidBrush(BackColor), ClientRectangle)
g.Dispose()
Return
End If
MyBase.WndProc(m)
End Sub
End Class
End Namespace
I use in a simple winform where there is a Button and the MyDatePickerControl
Nothing else
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
DateTimePicker1.BackColor = Color.Yellow
DateTimePicker1.Invalidate()
End Sub
When I click on the button the DateTimePicker back color do not change and I spent hours to understand why
Can you help Me ?
Continue reading...