Page 1 of 2

DateTimePicker

Posted: 17 Jul 2009, 14:17
by itmg
Hi,

when setting "CurrentDate = Null" I'm getting a run time error 94.
Do it only support a numeric 0 value, to show that's no date set?
The DateTime datafield in the sql server table, which the datetimepicker is accessing, have a null value (NULL), but the control shows #12/31/1899#.
I thought the behaviour of the control is identical with the DateTimePicker from Microsoft.

Re: DateTimePicker

Posted: 17 Jul 2009, 18:04
by TiKu
I assume you have set AllowNullSelection set to True?
Nevertheless, I see what you mean. Microsoft has chosen the data type Variant for the Value property, so this property can be set to Empty (I guess this is what the NULL value gets translated to) and Empty means "no date selected". I have chosen the data type Date for the CurrentDate property, so this property cannot be set to Empty. To remove the check mark, the property "DateSelected" must be set to False. I did not think about data binding or better: I did not think about the situation that the database field that is bound to the CurrentDate property, contains NULL values.

Changing the type of the CurrentDate property cannot be done without breaking compatibility. The only thing I could do, is to add a new property of type Variant that can be used alternatively. Having two properties for the same task is no good design, but it's the only thing I could do.
Let me know whether you really need such a new property.

Re: DateTimePicker

Posted: 20 Jul 2009, 09:29
by itmg
When you adding a new property of type Variant, would it be used for databinding instead of the "currentDate" property.
The control must show a real NULL value and it must be able to set a real NULL value.

Re: DateTimePicker

Posted: 20 Jul 2009, 17:38
by TiKu
This new property (let's call it "Value") could be used as a replacement for the "CurrentDate" and "DateSelected" properties. If "Value" was set to a Date value, the control would behave as if "DateSelected" was set to "True" and "CurrentDate" was set to the Date value. If "Value" was set to "Empty" (I assume this is what the NULL value gets translated to by COM), the control would behave as if "DateSelected" was set to "False".
The "Value" property would be supported for data binding, yes.

This is the behavior you need, right?

Re: DateTimePicker

Posted: 21 Jul 2009, 09:09
by itmg
Yes! That would be great.
But "Value" should be to set to Null, not Empty.
In VB this should be True:

Code: Select all

VarType(DTPicker1.Value) = VbVarType.vbNull
Thanks a lot.

Re: DateTimePicker

Posted: 21 Jul 2009, 23:28
by TiKu
Please have a look at the attached build of DateTimeControls. The DateTimePicker control now has a Value property that should behave exactly as described in this thread.

Re: DateTimePicker

Posted: 22 Jul 2009, 13:50
by itmg
Hi

I've tested it.
In the data binding dialog I can set the datasource and datafield for the bound property "value".
Wouldn't it be nicer the user can choose the default bound property? May be with an extra enum property.

During run time it's impossible to change the right data binding. The control binds "CurrentDate", always.

Best regards

Re: DateTimePicker

Posted: 22 Jul 2009, 14:17
by TiKu
Currently the CurrentDate property is defined as default bound property. This is done by setting an IDL attribute (defaultbind) for this property. My knowledge about data binding is very limited, but I wouldn't expect that setting the defaultbind attribute prevents any other bindable property from being bound.
I'll remove the defaultbind attribute from the CurrentDate property (I hope this won't break binary compatibility). Maybe this helps.

I'll post a new build this evening.

Re: DateTimePicker

Posted: 22 Jul 2009, 18:06
by TiKu
I've removed the defaultbind attribute from the "CurrentDate" property and set it for the "Value" property. I hope it will work now (can't test it myself here).

Re: DateTimePicker

Posted: 23 Jul 2009, 14:39
by itmg
Hi,
great job!
It works fantastic!
Thanks!

Re: DateTimePicker

Posted: 10 Jan 2010, 21:40
by jadranko
Dear,

You did very good job.
However, I have to ask you one favor. If you have noticed, a lot of people search for datetime picker control that can be nullable and it is main reason why they don’t like MS DTPicker control. That means user has to be capable to delete value of date inside of control. Control in that case must show empty string instead of dimmed date. Deletion could be done either by pressing delete key till focus is inside of control or selecting check box (if property “CheckBox” is “True”). Dimmed valued of date is confusing users and sometime they are not aware that date is not selected.
Also, I suggest to have additional option for "Style" property that would cover both existing styles because sometimes user want to change date just for few days and sometimes they like to pick a date, thus both up-down and drop-down possibilities have to be present in the same time.

Is it possible to do that?

Re: DateTimePicker

Posted: 10 Jan 2010, 22:15
by TiKu
jadranko wrote:You did very good job.
Thanks.
jadranko wrote:However, I have to ask you one favor. If you have noticed, a lot of people search for datetime picker control that can be nullable and it is main reason why they don’t like MS DTPicker control. That means user has to be capable to delete value of date inside of control. Control in that case must show empty string instead of dimmed date. Deletion could be done either by pressing delete key till focus is inside of control or selecting check box (if property “CheckBox” is “True”). Dimmed valued of date is confusing users and sometime they are not aware that date is not selected.
My controls are based on the native Windows controls. Unfortunately the native date time picker control doesn't support this and I cannot think a reliable way how to provide such a feature without native support.
jadranko wrote:Also, I suggest to have additional option for "Style" property that would cover both existing styles because sometimes user want to change date just for few days and sometimes they like to pick a date, thus both up-down and drop-down possibilities have to be present in the same time.
Same here. It would be possible to display an up-down button next to the actual control, but this would look ugly. If you really need this, it's easy to implement it on your own. Just create a composited control that consists of my control and an up-down control and add a bit of logic to connect them.

Re: DateTimePicker

Posted: 22 Apr 2012, 14:44
by TISP
When setting the maxdate property, also the mindate property is set to 14-9-1752.
When setting the mindate property, also the maxdate property is set to 31-12-9999.
Would it be possible to leave the maxdate property unchanged when setting the mindate an to leave the mindate property unchanged when setting the maxdate? (As in the original date picker)

Many thanks in advance.

Re: DateTimePicker

Posted: 22 Apr 2012, 15:28
by TiKu
Hi,

I can reproduce this behavior. Looks like Microsoft messed up the API documentation. I'll provide a fix.

TiKu

Re: DateTimePicker

Posted: 22 Apr 2012, 16:36
by TiKu
Version 1.3.1 has been released, it fixes the problem.

Regards
TiKu