Hello,
In RadGridView, I set the column to GridViewDateTimeColumn.
I want to change the date display format to short.
Code below.
Public Class RadForm5
Private Sub RadForm5_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim listTest As New List(Of TestDate)
listTest.Add(New TestDate With {.Name = "John", .DateStart = New Date(2022, 5, 1)})
listTest.Add(New TestDate With {.Name = "Arya", .DateStart = New Date(2022, 5, 2)})
listTest.Add(New TestDate With {.Name = "Brandon", .DateStart = New Date(2022, 5, 3)})
listTest.Add(New TestDate With {.Name = "Catelyn", .DateStart = New Date(2022, 5, 4)})
For Each col In RadGridView1.Columns
If col.Name = "colDate" Then
col.FieldName = "DateStart"
Dim colDate As GridViewDateTimeColumn = TryCast(col, GridViewDateTimeColumn)
colDate.Format = DateTimePickerFormat.Short
End If
Next
RadGridView1.DataSource = listTest
End Sub
End Class
Public Class TestDate
Public Property Name As String
Public Property DateStart As Date
Public Sub New()
End Sub
End Class
Unfortunately, setting the display format does not work properly.
I have to add more fields in object every time
Public ReadOnly Property DateStartStr As String
Get
Return DateStart.ToShortDateString
End Get
End Property
And
col.FieldName = "DateStartStr"
Is there another way to do this?
Regards
Jack