Currently DateTime.ToShortDateString will not include any "0" prefixes. I think this makes any vertical lists of dates look funky:
Here is a very simple extension method that will append any needed leading "0" to the date:
namespace ParaPlan.Extensions { public static class DateHelper { public static string ToShortDateEqualLengthString(this DateTime dt) { var rv = new StringBuilder(); if (dt.Month.ToString().Length ==1) { rv.Append("0"); } rv.Append(dt.Month.ToString()); rv.Append("/"); if (dt.Day.ToString().Length == 1) { rv.Append("0"); } rv.Append(dt.Day.ToString()); rv.Append("/"); rv.Append(dt.Year.ToString());
return rv.ToString(); } } }
Changing our dates to call .ToShortDateEqualLengthString will make our listbox look much more pretty:
|