New to Telerik UI for WinForms? Download free 30-day trial

How to Format the Time Separator in RadChat


Product Version Product Author
2022.1.222 RadChat for WinForms Desislava Yordanova


RadChat offers the ChatElement.MessagesViewElement.TimeSeparatorInterval property that controls the time interval between messages that will trigger the automatic addition of a Time separator. You can set this property to 24 hours in order to display the time separator once when the date has changed.

format-chat-time-separator 001

When a new message is added, the TimeSeparatorAdding event is fired. It gives you the opportunity to control whether to add a time separator or not no matter the already specified TimeSeparatorInterval.

A common requirement is to format the time separator in a specific way. This article demonstrates a sample approach how to control what text to be displayed for the time separator.


It is appropriate to use the ItemFormatting event and specify the exact text you want to see for the separator:

format-chat-time-separator 002

private void RadChat1_ItemFormatting(object sender, ChatItemElementEventArgs e)
    ChatTimeSeparatorDataItem separator = e.ItemElement.Data as ChatTimeSeparatorDataItem;
    if (separator != null)
        ChatTimeSeparatorMessage msg = separator.Message as ChatTimeSeparatorMessage;
        e.ItemElement.Text = msg.TimeStamp.ToString("dd-MM-yyyy");

Private Sub RadChat1_ItemFormatting(ByVal sender As Object, ByVal e As ChatItemElementEventArgs)
    Dim separator As ChatTimeSeparatorDataItem = TryCast(e.ItemElement.Data, ChatTimeSeparatorDataItem)

    If separator IsNot Nothing Then
        Dim msg As ChatTimeSeparatorMessage = TryCast(separator.Message, ChatTimeSeparatorMessage)
        e.ItemElement.Text = msg.TimeStamp.ToString("dd-MM-yyyy")
    End If
End Sub

See Also

In this article