Starting afresh the new KryptonDateTimePicker is starting to look like the finished product although there is still one major feature yet to be completed. I have tried to add the same set of properties as the standard windows version to make it easy to upgrade to the new control. I hope in most cases a simple find/replace of the class name will be enough to get people up and working. Although I cannot promise there will not be edge cases where you need to spend extra time manually checking/updating.
Here we have the control displayed with each of the four Format property settings of Long, Short, Time and Custom. The associated CustomFormat is defined as “MMMM dd ‘at’ hh:mm tt“.

Clicking the drop down button presents the new KryptonMonthCalendar control inside a KryptonContextMenu instance that allows the selection of a new date. The DropDown event is fired before the calendar is displayed and allows you to customize the context menu with additional menu items as required. This could be very handy if you need to add extra options such as predefined date selection.

As with the standard control you can show a check box that allows the user to specify that the date should be null. In fact I have added an extra property called ValueNullable that will help with annoying data binding scenarios. The Value property works like the standard control and always returns a DateTime value but ValueNullable will return DBNull when the check box is cleared and return a DateTime when the check box is set. That should making binding against database columns easier.
Use ShowUpDown to show a pair of spin buttons instead of the default drop down button. As with most Krypton controls you can use ButtonSpec definitions to add extra buttons to the control area.

Text Editing
The one feature currently missing, and my next task, is the ability to modify the text area using the keyboard. I need to take the focus and highlight the different fragments of text such as just the month, day, hours and so forth. Then allow the up/down buttons and other keyboard actions to modify the value. This requires parsing the format and working out the correct drawing of different sections. Not that hard but it requires quite a bit work to get it working smoothly.
February 25th, 2009 at 6:12 pm
Really looking forward to this one, Phil. There’s a huge break in my GUI with those Winforms-DateTimePickers.
I don’t know if I got it all right … Is it possible to handle null-values without the Checkbox by deleting the inner Text or clicking a “clear” button on the dropdown?
February 26th, 2009 at 12:15 am
Will we have the ability to display text such as “Click To Set” if the date is currently null?
February 26th, 2009 at 12:45 am
I’m with Waescher. While it might require you to get the text editing part working first, have nothing displayed in the text area would be the most intuitive way of displaying null values. That’s how I currently do it in a hacked WinForms control based on some ideas from a CodeProject article (that I’ve misplaced the link).
For handling the Value property’s value in the above method’s null case, there could be a way for the user to specify how to handle it. It could return either the Now, Minimum, or user specified DateTime value when the state is null.
Also for the NullableValue property, could it be just a DateTime? instead of returning a DBNull?
February 26th, 2009 at 3:13 am
Wow!!! Looks great Phil. I love the idea of the ContextMenu but I’m curious if that is something we have to manually “create” by dragging on a ContextMenu or will it be a default child object (like a Panel) in the KryptonDateTimePicker?
The NullableValue property is definitely a step in the right direction and would handle my use. I am curious though how hard it would be to add some extended configuration so that we could substitute a preset date or string in the event the CheckBox was false. Obviously this could be done in code by checking the Checked state but it won’t be directly bindable if you need something besides null.
To answer Waescher question (partially), you don’t have to show the CheckBox and could set it’s value using a clear ButtonSpec causing the value to appear to binding as if it were cleared. Hope that sheds some light.
February 26th, 2009 at 6:04 am
Phil, are you going to change the rendering to show it 22 pixels tall or keep it at 20? Also, I’m sure you’ve noticed but the CheckBox is placed with irregular padding.
February 26th, 2009 at 2:53 pm
When the control has a null value (the checkbox is cleared) the Value property still returns an actual DateTime. (This is the same as for the standard DateTime control). But the ValueNullable property will return DBNull. The ValueNullable cannot be defined as DateTime? because the property grid control in Visual Studio cannot handle the display of nullable types.
I will look into making the control a little taller so it has a nicer looking check box padding. Although most people do not use the check box functionality.
The idea of showing some predefined text when the value is empty is interesting but I am not sure it is ideal. When null the control still does have a date and it is displayed in the disabled colors so it is less obvious.
February 28th, 2009 at 5:53 am
Here is an example of how I would use a null value of Click To Set
http://members.cox.net/jimpar2/NullDate.jpg
March 3rd, 2009 at 8:47 am
Jay, nice SS. I hope you don’t mind me suggesting something.
Try to change your KryptonHeader (that contains the Add Items and Update All Packed buttons) into a KryptonHeaderGroup. Dock your items grid into that KHG, and set the grid to HideOuterBorders = True. This will get rid of the double border you have at the top of the grid while maintaining the border around the grid.
If you have any questions please feel free to PM me on the forums.
March 4th, 2009 at 5:14 am
I don’t mind suggestions at all. This control is a KryptonHeaderGroup. There is a Panel on it and then the grid is created at runtime and the parent of the grid is the panel. I did set HideOuterBorders = True and the double border did go away.
Thanx
March 5th, 2009 at 5:12 am
If you’re building from scratch, one feature I’d love to see is support for fractional seconds in CustomFormat,( “H:mm:ss.ff” yeilds “01:23:45.67″), which isn’t supported by native DateTimePicker.
Thanks!