Format Date Group Header

2 posts, 1 answers
  1. Justin
    Justin avatar
    8 posts
    Member since:
    Aug 2011

    Posted 27 Jan 2013 Link to this post


    I am grouping a ListView in DetailsView on a databound DateTime column. I can format the CellElement.Text for the column using the cell formatting event:

    Private Sub radListView3_CellFormatting(sender As Object, e As Telerik.WinControls.UI.ListViewCellFormattingEventArgs) Handles RadListView3.CellFormatting
        If e.CellElement.Data.HeaderText = Me.RadListView3.Columns("NoteDate").HeaderText And TypeOf (e.CellElement) Is DetailListViewDataCellElement Then
            e.CellElement.Text = [String].Format("{0:D}", (DirectCast(e.CellElement, DetailListViewDataCellElement)).Row(e.CellElement.Data))
        End If
    End Sub

    But how can I format the group header to display the long date format as well?

  2. Answer
    Anton avatar
    167 posts

    Posted 30 Jan 2013 Link to this post

    Hi Justin,

    Thank you for writing.

    You can format the headers of the groups through by accessing them via the Groups collection or by using the VisualItemFormatting event of the RadListView:
    Me.radListView1.Groups(0).Text = "My text"

    Private Sub radListView1_VisualItemFormatting(sender As Object, e As ListViewVisualItemEventArgs) Handles RadListView1.VisualItemFormatting
        Dim item As DetailListViewGroupVisualItem = TryCast(e.VisualItem,
        If item IsNot Nothing Then
            item.Text = "My text"
        End If
    End Sub

    I hope this helps.

    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  3. DevCraft R3 2016 release webinar banner
Back to Top