This is a migrated thread and some comments may be shown as answers.

Format Date Group Header

1 Answer 130 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 27 Jan 2013, 10:26 AM
Hi,

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?

1 Answer, 1 is accepted

Sort by
0
Accepted
Anton
Telerik team
answered on 30 Jan 2013, 05:50 PM
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,
DetailListViewGroupVisualItem 
)
    If item IsNot Nothing Then
        item.Text = "My text"
    End If
End Sub

I hope this helps.

Regards,
Anton
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Tags
ListView
Asked by
Justin
Top achievements
Rank 1
Answers by
Anton
Telerik team
Share this question
or