LOGIN    REGISTER    YOUR CART

homepage
VisualHint's blog
May02

The ten deceptions of the DateTimePicker

If you are here reading these lines it’s because you have something against the .Net DateTimePicker. And you’re not alone since, if you do a search in the newsgroups, the same questions keep coming: “how do I set the background color of the DTP?”, or “it does not accept a null value and my DateTime column in my database has some empty cells”.

CodeProject and other similar developer communities give you a lot of pseudo solutions to solve one or two issues of the control… when they don’t create new problems. They start with deriving from the DateTimePicker class and overriding certain methods and end with the magic textbox displayed in front to hide the date value when null is the only thing desired. So it’s obvious that everyone complains about the DateTimePicker shortcomings and everyone needs a solution. What are the problems of this component which is, don’t forget it, the underlying win32 SysDateTimePick32 window class, nothing more:

  1. The complaint number one is that it doesn’t accept a null or DBNull value. This is critical when binding it to a nullable DateTime column in a database. Consequently it’s not possible to display a custom string when this value is null.
  2. It suffers some display issues: when closing the calendar, the focus cue disappears, except if a checkbox is visible, in which case this is the one taking the focus. Speaking of the checkbox, it will sometimes show this cue even when the control itself is not focused. No mouse hover effect is seen on the dropdown button and checkbox, however there is one for the updown button. And don’t ask me why you can’t show an updown button with a dropdown button at the same time…
  3. There are also some inconsistencies compared to the usual combobox and checkbox controls. When clicking those buttons, the corresponding action is triggered on mouse down instead of being triggered on mouse up.
  4. If you disable the date by clicking on the checkbox, which is by the way ridiculously small under a non xp theme, clicking the dropdown button instantly reenables it.
  5. There is no text formatting options except for the month calendar. The background color can’t be set.
  6. Programmatically you can’t control which field is the selected one.
  7. This is the same for the dropdown calendar. You won’t be able to show it or hide it without the user intervention.
  8. Some people would like a way to automatically jump to the next editable field when all characters have been typed in the current field instead of having to type the right arrow key each time.
  9. Where are callback fields? Do you remember the DTNFORMATQUERY and DTNFORMAT messages? It was great to create custom fields but this feature is not natively present in the .net control.
  10. No custom culture can be applied on the displayed string. The Microsoft KB says it clearly: you can do it only by changing the current culture in the control panel. Pretty annoying for applications that want to change this regional setting on the fly, usually when choosing a language in a preferences box.

There are some more issues that I had, specifically in Smart PropertyGrid.Net. Among the built-in inplace controls this was the only one to vertically align the text at the top. No way to change that. When a property expands on multiple rows or simply increases its vertical margin this is not very nice. Also, a field calculates its width based on the largest string it can accept (“September” for the month for example). This was also an issue with SPG. When the inplace control was not active, I had no way to display the text with the same spacing between fields and therefore when selecting the datetime property, all the fields were shifting in a non pleasant way.

I guess there are some more concerns that you encountered while coping with the DateTimePicker. You can add them in the comments so that we have a good starting list to know what else needs to be fixed.

Apr30

The perfect DateTimePicker? Not only!

It is well known that a good product is one that provides a solution to your own problem, and as a result would meet the needs of a wider audience. Some time ago I discovered a problem in SPG.Net. I couldn’t make a true DateTimePicker inplace control achieving the level of quality of the overall product. The win32 control from Microsoft has so many issues and inconsistencies that it was a nightmare trying to work around them. Finally I decided to remove this inplace control from SPG and announced it to my customers. I was really dissatisfied by this decision but I had no other choice. Time passed and I was still sure there was nothing I could do about it. I then came to the conclusion that I could rewrite a DateTime picker from scratch but at first I was discouraged because I didn’t know where to start.

This is quite typical. Let time go by and one day you find the courage. I began slowly, one small thing at a time and sooner than expected I had a base control to work with. Instead of tying it to datetime specific requirements, I made the effort of designing it as a generic editor able to edit a series of rule-based fields, a rule being for example “an integer in a specific range”. Smart FieldPackEditor was born but it didn’t know it yet.

I was whispering to myself “it would be great if it could be a standalone product but I guess that many component vendors, and especially the big ones, have already covered this domain”. Guess what? No! I found absolutely no “field editor” controls and concerning DateTimePickers I found only two but one seems to emphasize only a vista look and feel, while the other one was so basic that I can’t even remember who offered it. All the other possibilities are in the “free” domain, mainly on CodeProject. They all derive from a DateTimePicker or a TextBox and try to do their best to fix one or several issues of the MS DTP but the result is never the perfect solution.

So, in essence what are the goals of SFPE:

  • To be the best (if not unique right now) DateTimePicker replacement of choice for the old MS DTP.
  • To be a generic framework able to let a user edit a set of fields where each field is governed by a rule.
  • To be extended via a derived class so that it is fully usable in SPG.Net and therefore will fix my initial problem.

I need your input to make this product an absolute must. So I have opened a new section in the forums and a mailing list on the homepage (so that you can be informed when the beta begins). Given what I wrote above, what do you think ? What are your features of choice ? What are the issues you want fixed first?

In a next post, I will try to summarize all the problems of the MS DTP and expose how SFPE fixes them.

Apr29

A new home for VisualHint

VisualHint has reached another milestone. Today, I’m launching my new web site that offers the GUI components that I design. The redesign was not out of boredom, but simply the result of a need to support more than one product. The previous site had been designed around a main product (Smart PropertyGrid) and the accompanying news section and I had no idea how to add another product which would have the same importance. Therefore, it was time for a redesign.

I took Xara Xtreme Pro, a very nice tool to quickly output vector drawings and began coding css and html pages. I must admit it was quite long for me because I’m not a web designer, but I like the process of being fully involved in the construction of my new home. That being said, I hope you will like it, as much as I do. Btw, here is a list of what changes were made during the redesign:

  • The previous blog was more a “news section” than a blog. I will now try to maintain a true blog discussing PropertyGrids, DateTimePickers and custom controls in general.
  • Comments and trackbacks are open for more communication with visitors and customers.
  • The homepage clearly presents the products, the latest announcement and the latest blog post.
  • The navigation is easier than before.

So now you would like to know more about this new product, is that it? To be followed on the next post…

Jan24

Value validation in great form

So far, value validation in SPG was simple and clean: no annoying popup but also the obligation to see the previous value automatically restored.

For the next release, value validation is being reworked. It will still offer the existing behavior but also a mode called KeepFocus. Under this new mode, the focus stays on the faulty value until the user types a valid value (this is what happens in the Microsoft PropertyGrid but unfortunately spoiled with the modal popup). Inside a new validation callback the client application will be given the choice to display a visual clue to indicate to the end-user that there is a problem. The best option will be to show the free Skybound VisualTip.

Here are two examples grabbed from my current build. In the first situation, an event is sent to the client application and indicates that a TypeConverter was not able to convert the value set by the user. The text of the exception is passed with the event and the client application made the choice to display it in a customized tooltip.

TypeConverter: invalid value

In the second situation, the user entered a value out of the range set by an attached PropertyValidatorMinMax class. The validator proposed a generic text but the client application made the choice to display a custom text.

Property Validator: invalid value

I must add that the visual capabilities of VisualTips are endless. Very nice product. Marry it with Smart PropertyGrid.Net and you succeed bringing the right experience to your end-users.

Jan02

PropertyValueChanged for collections bug fix

I was not aware of this bug in the Microsoft PropertyGrid until a customer told me it was doing the same thing in Smart PropertyGrid. This is interesting enough to add a post here about it. The issue is that PropertyValueChanged is not fired for certain collections. It works with an array but doesn’t for a List<> for instance. The reason is that the UITypeEditor.EditValue(...) method returns the reference on the original collection even if its content has been modified. I looked in Reflector and after this method returns, the Microsoft code does a simple “if (obj1 != obj2) ...” which of course returns false and doesn’t trigger the event. My code was actually doing the same thing, so I fixed it to handle this particular case. This is another reason to purchase from a small company that reacts and makes a product that evolves fast. This enhancement is available in version 2.1 beta2 that is out today.

Oct17

A website for PropertyGrid resources

I launched today a new web site, minimalist in page count, intended to .Net developers who use the Microsoft PropertyGrid (and secondarily Smart PropertyGrid.Net since it understands all the framework classes related to Type discovery). Because this is sometimes difficult to get the right information for developers who start using this complex component, it seems it was essential to have a well known page referencing all famous and less famous articles, forum posts and other various materials. I don’t want to spend time on developing the web site itself, but surely want to enrich its content with my findings and your submissions. Even nice tips and tricks can fit there. The address is www.propertygridresourcelist.com.

Sep21

Navigate with the TAB key in a PropertyGrid

Navigate the PropertyGrid with the TAB key This feature is one of the most discussed about PropertyGrids in general, whether they are mfc, activeX or .net controls from third party developers. The model provided by Microsoft does not offer the possibility to navigate from value to value with the TAB key, or shift+TAB for reverse order and this is a lack that annoys a lot of people. One of my customers had a long discussion with me about this feature. He wanted absolutely this kind of navigation to help his end-user edit a long list of mandatory variables. Using Return and Escape plus the arrow keys was not enough to provide a good experience to his own customers. Since that time, several other visitors and customers asked me the same feature. After visiting some developer forums and articles, I was convinced that browsing property values with the TAB key would be a must for Smart PropertyGrid.Net. So here is what I came with:

  • You are now able to choose between two major modes. In the first one you need to validate or cancel the current edition of the value and use the arrow key to go to the next editable property. In the second one , you navigate to the next inplace control with TAB and to the previous with shift+TAB. There are also several non-exclusive options for all tastes:

  • The "TabKeyWithAutoFocus" option will focus inside an inplace control as soon as you click on a property label. This is a great way to minimize the actions required by the end-user.

  • The "TabKeyInSubControls" option will allow to access child components in inplace controls. For example, for a trackbar feel, TAB will first go in the textbox part and another TAB will jump to the slider.

  • The "TabKeyInChildProperties" option will open any collapsed hierarchy to place the focus in the next editable property value.

  • The "TabKeySkipReadonlyProperties" option will skip readonly properties. Without it, these properties are visited so that a clipboard copy operation is possible while navigating the grid with the keyboard.

  • At last, the "TabKeyLeavesAtExtremes" option will normally tab to the remaining controls in a form once the top or bottom properties are edited. Without it, the focus will continue to rotate in the PropertyGrid.

There will be a small sample available to showcase all those modes in a few days.

Aug01

SelectedObjects ... with a final ‘s’

Since the release of the major version 1.5 with the support of Microsoft UITypeEditor classes is not far away and because many people are asking:

Yes, SelectedObjects allowing to select multiple target instances in the PropertyGrid is the next major feature to be developed. Once done, this should definitely show that Smart PropertyGrid.Net has now an extensive list of features and can be used as a stable base for even more enhancements in the future.

Jul03

The next major feature

"Smart PropertyGrid.Net will now support Microsoft UITypeEditors (dropdown and modal), the built-in ones provided in the .Net framework as well as the custom ones you have created."

In this post I wanted to announce that I was working on the first of the next major features available in SPG.Net 2.0. But this is a feature that many people requested and therefore I will answer to this wish by creating shortly a version 1.5 that will integrate it, even if officially this is a "2.0" feature.

The reason to add support for "legacy" (hehe, sorry, couldn’t resist) Type Editors is that my customers often take time to migrate their application to the new way SPG is working. In fact every client application using SPG should reasonnably stop using SelectedObject but I understand time and budget constraint matters and to allow easy switching between the Microsoft PropertyGrid and SPG, UITypeEditors must be fully handled.

If you have any questions or specific needs related to Microsoft UITypeEditors, please contact me and we will discuss while this is still in the works.

ShortcutKeys UITypeEditor

Dock UITypeEditor

Jun01

Incredible month of May

I would like to thank all the companies and individuals who suddenly transformed nice sales into a tremendous success. The month of May has been outstanding in terms of sales. As a consequence, my helpdesk system is also showing more and more messages from all of you. I get some "thank-you" for this unique product alongside the Microsoft PropertyGrid, I get new feature requests and also troubleshooting and problem reports ... all the things that will make Smart PropertyGrid continue to grow and become always more stable. Just to give you an idea, here is a blind graphic of my sales since last November:

Sales of May

As you can see the first day of June just looks very promising... This chart can be read in terms of income or in license count. It doesn't show the full site licenses since they are an infinite number of licenses for a company site.