DateTimePickers.Checked Problems

  • Thread starter Thread starter Marco Castro
  • Start date Start date
M

Marco Castro

Is it just me or does the Checked property of the DateTimePickers not work
properly?
I was trying to set it to off (which should disable the editing of the
control) to indicate that its a null value.
However sometimes when I do set it to off the control doesn't change. If
you read back the value it will say thats its not checked but the controls
is still checked and you can edit the values.
I can't even see a patern to when it decides to do it. Does anyone have an
explanaition for this and hopefully a work around? Thanks for any help.
 
* "Marco Castro said:
Is it just me or does the Checked property of the DateTimePickers not work
properly?
I was trying to set it to off (which should disable the editing of the
control) to indicate that its a null value.
However sometimes when I do set it to off the control doesn't change. If
you read back the value it will say thats its not checked but the controls
is still checked and you can edit the values.
I can't even see a patern to when it decides to do it. Does anyone have an
explanaition for this and hopefully a work around?

I have heard about this problem several times. Maybe calling the
control's 'Update' method (or something like that) will fix the problem.
 
Marco,

The datetime picker control does behave differently in one aspect from VB6,
which I believe is bug. Assuming you set the value of the control on form
initialization, I have found that the first change event is not fired when
the user clicks the check box.

As a work around on form initialization I have found it necessary to
initialize the value and the checked status of the DTP control (in this
order) and then set the actual values, for instance:

Me.dtpStartDate.Value = Now()
Me.dtpStartDate.Checked = False

.... set the appropriate values

You must understand that un-checking the control does NOT (a) disable the
control (b) set the value to null. Un-Checking the control only makes the
control appear to be disabled, further clicking or drop down of the picker
will automatically enable the control.

Regards,
Dan
 
I tried that and it didn't work for me. I did figure out what the problem
is tough.

Aparently if you try to set a value to the control while the checkmark is
off it will turn it on and enter the value. It won't however turn it back
off after and more importantly it does not change the Checked property.

So I just reset the control to on at the start of every record that is being
read and if its null I turn it off AFTER its been updated. That solved my
problem. Thanks for the help anyways.
 
Back
Top