Suggested change: Sortable Date/Time that is culture-aware

Jan 21, 2010 at 3:31 PM
Edited Jan 21, 2010 at 3:33 PM

The current implementation uses a hard-coded Date/Time format that may not be acceptable to everyone around the world.  Here's a suggestion:

Define a new property in MainForm.cs as follows:

        /// <summary>
        /// Returns a sortable date/time pattern that includes fractions of a second
        /// </summary>
        public string SortableDateTimePatternWithFractionalSeconds
                return System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.SortableDateTimePattern.Replace("ss", "ss.ff");

 Create a MainForm_Load event as follows: 

        private void MainForm_Load(object sender, EventArgs e)
            // use culture-specific sortable date/time that includes fractions of a second
            this.colDateTime.DefaultCellStyle.Format = SortableDateTimePatternWithFractionalSeconds;

Change the definition of the date/time cell in the grid to add the following property (as viewed in MainForm.Designer.cs to make things simple):

this.colDateTime.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;


Jan 26, 2010 at 12:25 PM

Thanks for your feedback. I will implement this in the next release.

Nov 5, 2013 at 9:57 AM
Check this app. support sorting for each column, also it support filter with custom values.