Custom Date Format for VB.NET Datagrid Column

  • Thread starter Thread starter simchajoy2000
  • Start date Start date
S

simchajoy2000

Hi,

I have a situation where I need to only display the month and day of a
specific date in my Datagrid Column while keeping the underlying value
(which includes the year) intact.

I am currently using a DataGridTimePickerColumn class I got from the
Microsoft website to create DateTimePickers in each row of my date
column. I am able to format the date how I want ("MM/dd") when the
user clicks on the DateTimePicker. But after they have entered the
date, the value (including the year) appears in the datagrid.

I've been trying to use the dataview to accomplish my goal of only
displaying the month and day to the user while keeping the whole date
intact in my datatable. But I have not been able to figure out how to
do this. Is what I am trying to do even possible?? And if so, does
anyone have any ideas of how I can do it??

Thank you!

Joy
 
Hi,

For the standard text column, such tricks can be achieved by supplying your
own Format string or even your own IFormatProvider instance by setting
appropriate properties of the column style (namely Format and FormatInfo).
Hopefully there are similar properties on the DateTimePicker column. If not,
derive a new column style, introduce these properties and use them in the
overloaded Paint method.
 
You are correct, Format properties are not provided for the
DateTimePicker column. I like your suggestion of creating a custom
column style, however, I'm not entirely sure where to begin. Is there
some example code out there that could help to guide me?

Thank you!

Joy
 
Back
Top