LOGIN    REGISTER    YOUR CART

homepage
VisualHint's blog
2007
May15

Solving all the issues of the DateTimePicker inside the DataGridView

Some days ago I came across a blog showing the trials and tribulations of a developer trying to display and use the standard DateTimePicker in the DataGridView. This story is really typical of all the considerable efforts one have to make in order to get a semi-viable solution. So far I was not even considering touching the DataGridView. It was an unknown component to me and I was not aware of its extensibility to enable custom editors to be used in a cell. After readind this article I jumped on the challenge and decided to integrate Smart FieldPackEditor.Net to the grid.

While SFPE is not even in beta yet, it took me one day to get almost everything running smoothly. By everything I mean:

  • Nice insertion of the editor inside a cell. No text shift. Back and Fore colors of the cell used by the editor.
  • Correct formatting of the datetime value.
  • Null values without a hitch.
  • Default keyboard handling.

Some nice features can be added to this list, making the use of this DateTimePicker as smooth as desired:

  • Correct field selection when clicking in the editor.
  • End of edition forced when closing the dropdown month calendar.
  • No fixed width fields, so that the text displayed by the grid is the same than the text displayed by the editor.
  • Choice of updown and/or dropdown buttons
  • And all the other benefits of the Smart FieldPackEditor…

As early as Tuesday 22, I will publish each day a series of four short screencasts. Here is the schedule:

  • Tuesday, overview of the FieldpackEditor.
  • Wednesday, how to handle the null value.
  • Thursday, SFPE, data binding and the DataGridView.
  • Friday, multi packs and other editors.