Вот как я это сделаю.
Сделайте вашу собственность, которая выставляет DateTime
(вместе) невидимой в DataGridView
.
Имеют два других свойства, Date
и Time
, и эти свойства по сути ссылаются на ваше свойство DateTime
.
Например:
[Browsable(false)]
public DateTime DateTime { get; set; }
public DateTime Date
{
get { return this.DateTime.Date; }
set
{
TimeSpan time = this.Time;
this.DateTime = value.Date + time;
}
}
public TimeSpan Time
{
get { return this.DateTime.TimeOfDay; }
set
{
this.DateTime = this.Date + value;
}
}