GridBuilder: Add SetDateTimeColumns
This commit is contained in:
parent
d718152a3f
commit
b4fa36469d
@ -1,5 +1,8 @@
|
||||
Imports System.Drawing
|
||||
Imports System.Globalization
|
||||
Imports System.Windows.Forms
|
||||
Imports DevExpress.Utils
|
||||
Imports DevExpress.XtraGrid.Columns
|
||||
Imports DevExpress.XtraGrid.Views.Grid
|
||||
Imports DevExpress.XtraTreeList
|
||||
|
||||
@ -64,6 +67,26 @@ Public Class GridBuilder
|
||||
Next
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Applies a proper datetime format string to all columns of the view.
|
||||
''' </summary>
|
||||
''' <remarks>The view's columns need to be loaded for this to work!</remarks>
|
||||
Public Sub SetDateTimeColumns(pView As GridView)
|
||||
If pView.Columns Is Nothing Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oDateColumns = pView.Columns.AsEnumerable.
|
||||
Where(Function(column As GridColumn) column.ColumnType = GetType(Date)).
|
||||
ToList()
|
||||
|
||||
For Each oDateCol In oDateColumns
|
||||
oDateCol.DisplayFormat.FormatType = FormatType.Custom
|
||||
oDateCol.DisplayFormat.FormatString = "g"
|
||||
oDateCol.DisplayFormat.Format = DateTimeFormatInfo.CurrentInfo
|
||||
Next
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Applies common properties to all GridViews
|
||||
''' </summary>
|
||||
@ -198,4 +221,5 @@ Public Class GridBuilder
|
||||
e.Handled = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user