I have a list of business logic objects that is bound to a Winforms DataGridView
, and it contains DateTime
fields. By default they get converted into a long date and time string.
I want the fields to be converted automatically into HH:MM
format. I've discovered that I can attach a TypeConverterAttribute
to a field with a subclass of TypeConverter
class, but I can't for the life of me figure out how to make DateTimeConverter
accept a custom format string. Is it possible without writing a custom TypeConverter
?
class Foo
{
...
// How to make this converter use a custom format string?
[TypeConverter(typeof(DateTimeConverter))]
public DateTime SomeDateField { get; private set; }
...
}