GUIs.Common: Formatierbare Datumsspalten-Funktionen ergänzt

This commit is contained in:
2026-03-06 11:17:06 +01:00
parent 538e2fcde1
commit 7173c89b77

View File

@@ -82,7 +82,7 @@ Public Class GridBuilder
ToList()
For Each oDateCol In oDateColumns
SetDateTimeColumn(oDateCol)
SetDateTimeColumn(oDateCol, "g")
Next
End Sub
@@ -96,19 +96,61 @@ Public Class GridBuilder
ToList()
For Each oDateCol In oDateColumns
SetDateTimeColumn(oDateCol)
SetDateTimeColumn(oDateCol, "g")
Next
End Sub
Private Sub SetDateTimeColumn(pColumn As GridColumn)
''' <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, pFormatString As String)
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
SetDateTimeColumn(oDateCol, pFormatString)
Next
End Sub
Public Sub SetDateTimeColumns(pTreeList As TreeList, pFormatString As String)
If pTreeList.Columns Is Nothing Then
Exit Sub
End If
Dim oDateColumns = pTreeList.Columns.AsEnumerable.
Where(Function(column As TreeListColumn) column.ColumnType = GetType(Date)).
ToList()
For Each oDateCol In oDateColumns
SetDateTimeColumn(oDateCol, pFormatString)
Next
End Sub
Private Sub SetDateTimeColumn(pColumn As GridColumn, pFormatString As String)
If String.IsNullOrEmpty(pFormatString) Then
pFormatString = "g"
End If
pColumn.DisplayFormat.FormatType = FormatType.Custom
pColumn.DisplayFormat.FormatString = "g"
pColumn.DisplayFormat.FormatString = pFormatString
pColumn.DisplayFormat.Format = DateTimeFormatInfo.CurrentInfo
End Sub
Private Sub SetDateTimeColumn(pColumn As TreeListColumn)
Private Sub SetDateTimeColumn(pColumn As TreeListColumn, pFormatString As String)
If String.IsNullOrEmpty(pFormatString) Then
pFormatString = "g"
End If
pColumn.Format.FormatType = FormatType.Custom
pColumn.Format.FormatString = "g"
pColumn.Format.FormatString = pFormatString
pColumn.Format.Format = DateTimeFormatInfo.CurrentInfo
End Sub