Home All Groups Group Topic Archive Search About

date time picker and validate event ( is this a bug ? )

Author
23 Nov 2006 10:28 AM
Michel Posseth [MCP]
I have a problem with the date time picker validate event wich i believe is
a bug


How to reproduce :

throw on a form a date time picker control and a textbox control

select the validating event of the control and add this code

Private Sub DateTimePicker1_Validating(ByVal sender As System.Object, ByVal
e As System.ComponentModel.CancelEventArgs) Handles DateTimePicker1.Validating
        TextBox1.Text = Me.DateTimePicker1.Text
    End Sub

start the project

change the standard value of the control but only the day or month ( not the
year )  now move away from the control with a tab

The textbox will show a different value as there is currently showed on your
screen by the date time picker 


does someone have a good explanation for this ?

regards

Michel

Author
23 Nov 2006 12:11 PM
Michel Posseth [MCP]
For people strugling with the same problem

i just found a workaround


create you own custom datetime picker ( copy  and paste this code  )

Option Strict On
Option Explicit On
Public Class CustomDateTimePicker
    Inherits DateTimePicker
    Protected Overrides Sub OnValidating(ByVal e As
System.ComponentModel.CancelEventArgs)
        MyBase.Visible = False
        MyBase.Visible = True
        MyBase.OnValidating(e)
    End Sub
End Class

This one behaves as expected , however if you have fast eyes or a slow
machine you might see a blink :-)


I consider the standard behavior as a bug

regards
Michel Posseth [MCP]




Show quoteHide quote
"Michel Posseth [MCP]" wrote:

>
> I have a problem with the date time picker validate event wich i believe is
> a bug
>
>
> How to reproduce :
>
> throw on a form a date time picker control and a textbox control
>
> select the validating event of the control and add this code
>
>  Private Sub DateTimePicker1_Validating(ByVal sender As System.Object, ByVal
> e As System.ComponentModel.CancelEventArgs) Handles DateTimePicker1.Validating
>         TextBox1.Text = Me.DateTimePicker1.Text
>     End Sub
>
> start the project
>
> change the standard value of the control but only the day or month ( not the
> year )  now move away from the control with a tab
>
> The textbox will show a different value as there is currently showed on your
> screen by the date time picker 
>
>
> does someone have a good explanation for this ?
>
> regards
>
> Michel
>
>
>
>
Author
24 Nov 2006 5:56 AM
Cor Ligthert [MVP]
Michel,

Validating a date-time picker?

Is that something they do in Rotterdam?

You can in my idea better validate if the water there is clear enough to
drink.

:-)

Cor

Show quoteHide quote
"Michel Posseth [MCP]" <MichelPosseth***@discussions.microsoft.com> schreef
in bericht news:F1830618-5B82-4EFF-9474-A6E08111EB7D@microsoft.com...
>
> I have a problem with the date time picker validate event wich i believe
> is
> a bug
>
>
> How to reproduce :
>
> throw on a form a date time picker control and a textbox control
>
> select the validating event of the control and add this code
>
> Private Sub DateTimePicker1_Validating(ByVal sender As System.Object,
> ByVal
> e As System.ComponentModel.CancelEventArgs) Handles
> DateTimePicker1.Validating
>        TextBox1.Text = Me.DateTimePicker1.Text
>    End Sub
>
> start the project
>
> change the standard value of the control but only the day or month ( not
> the
> year )  now move away from the control with a tab
>
> The textbox will show a different value as there is currently showed on
> your
> screen by the date time picker
>
>
> does someone have a good explanation for this ?
>
> regards
>
> Michel
>
>
>
>
Author
24 Nov 2006 7:47 AM
Michel Posseth [MCP]
Well Cor ,,,


I currently work in a energy company  , an we write software that calculates
energy bills .

A bill has to be made in a certain range of a time span

so before we create new entry`s in the database we would like to "validate"
this entered range,  however it gets a bit tricky if the value that is showed
is different from the one that is in memory

have you tried my example of the problem ?   , try it out and you will see
that this must be a serious bug .

by the way i found that this is enough to solve the problem

Option Strict On
Option Explicit On
Public Class CustomDateTimePicker
    Inherits DateTimePicker
    Protected Overrides Sub OnValidating(ByVal e As
System.ComponentModel.CancelEventArgs)
        MyBase.Visible = True
        MyBase.OnValidating(e)
    End Sub
End Class


regards

Michel





Show quoteHide quote
"Cor Ligthert [MVP]" wrote:

> Michel,
>
> Validating a date-time picker?
>
> Is that something they do in Rotterdam?
>
> You can in my idea better validate if the water there is clear enough to
> drink.
>
> :-)
>
> Cor
>
> "Michel Posseth [MCP]" <MichelPosseth***@discussions.microsoft.com> schreef
> in bericht news:F1830618-5B82-4EFF-9474-A6E08111EB7D@microsoft.com...
> >
> > I have a problem with the date time picker validate event wich i believe
> > is
> > a bug
> >
> >
> > How to reproduce :
> >
> > throw on a form a date time picker control and a textbox control
> >
> > select the validating event of the control and add this code
> >
> > Private Sub DateTimePicker1_Validating(ByVal sender As System.Object,
> > ByVal
> > e As System.ComponentModel.CancelEventArgs) Handles
> > DateTimePicker1.Validating
> >        TextBox1.Text = Me.DateTimePicker1.Text
> >    End Sub
> >
> > start the project
> >
> > change the standard value of the control but only the day or month ( not
> > the
> > year )  now move away from the control with a tab
> >
> > The textbox will show a different value as there is currently showed on
> > your
> > screen by the date time picker
> >
> >
> > does someone have a good explanation for this ?
> >
> > regards
> >
> > Michel
> >
> >
> >
> >
>
>
>
Author
24 Nov 2006 5:25 PM
Cor Ligthert [MVP]
Michel,

Don't take it serious, I saw the validating event and than thought is that
the right place, I made the message. After a while I thought, you are of
course testing the given date to certain possibilities, not if the given
date is correct.

I can assure you that I don't have to test things you say, I take it on your
word.

However sometimes I can not resist.

Cor

Show quoteHide quote
"Michel Posseth [MCP]" <MichelPosseth***@discussions.microsoft.com> schreef
in bericht news:BB842582-89E4-4DE4-B4AF-D7819333E06E@microsoft.com...
> Well Cor ,,,
>
>
> I currently work in a energy company  , an we write software that
> calculates
> energy bills .
>
> A bill has to be made in a certain range of a time span
>
> so before we create new entry`s in the database we would like to
> "validate"
> this entered range,  however it gets a bit tricky if the value that is
> showed
> is different from the one that is in memory
>
> have you tried my example of the problem ?   , try it out and you will see
> that this must be a serious bug .
>
> by the way i found that this is enough to solve the problem
>
> Option Strict On
> Option Explicit On
> Public Class CustomDateTimePicker
>    Inherits DateTimePicker
>    Protected Overrides Sub OnValidating(ByVal e As
> System.ComponentModel.CancelEventArgs)
>        MyBase.Visible = True
>        MyBase.OnValidating(e)
>    End Sub
> End Class
>
>
> regards
>
> Michel
>
>
>
>
>
> "Cor Ligthert [MVP]" wrote:
>
>> Michel,
>>
>> Validating a date-time picker?
>>
>> Is that something they do in Rotterdam?
>>
>> You can in my idea better validate if the water there is clear enough to
>> drink.
>>
>> :-)
>>
>> Cor
>>
>> "Michel Posseth [MCP]" <MichelPosseth***@discussions.microsoft.com>
>> schreef
>> in bericht news:F1830618-5B82-4EFF-9474-A6E08111EB7D@microsoft.com...
>> >
>> > I have a problem with the date time picker validate event wich i
>> > believe
>> > is
>> > a bug
>> >
>> >
>> > How to reproduce :
>> >
>> > throw on a form a date time picker control and a textbox control
>> >
>> > select the validating event of the control and add this code
>> >
>> > Private Sub DateTimePicker1_Validating(ByVal sender As System.Object,
>> > ByVal
>> > e As System.ComponentModel.CancelEventArgs) Handles
>> > DateTimePicker1.Validating
>> >        TextBox1.Text = Me.DateTimePicker1.Text
>> >    End Sub
>> >
>> > start the project
>> >
>> > change the standard value of the control but only the day or month (
>> > not
>> > the
>> > year )  now move away from the control with a tab
>> >
>> > The textbox will show a different value as there is currently showed on
>> > your
>> > screen by the date time picker
>> >
>> >
>> > does someone have a good explanation for this ?
>> >
>> > regards
>> >
>> > Michel
>> >
>> >
>> >
>> >
>>
>>
>>