Windows Forms DataGridView Formatting
31-Oct-1313 Leave a comment
Time Formatting
To format Null set the Null Value in designer, or code for empty string.
Found when binding to a POCO class with TimeSpan that had some errors with some formats. hh\:mm seems to work.
http://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx
To format 00:00 as blank then:
Private Sub TimeDataGridView_CellFormatting(sender As System.Object, e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles TimeDataGridView.CellFormatting If e.ColumnIndex <> myColumn.Index Then Exit Sub End If If e.Value = New TimeSpan(0, 0, 0) Then e.Value = "" e.FormattingApplied = True End If End Sub End