Custom Date Format for VB.NET Datagrid Column

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
 
D

Dmytro Lapshyn [MVP]

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.
 
S

simchajoy2000

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top