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

TextMessage Colors

1 Answer 33 Views
Conversational UI, Chat
This is a migrated thread and some comments may be shown as answers.
Todd
Top achievements
Rank 1
Todd asked on 15 Nov 2018, 07:58 AM

Hi there,

     I'd like to modify the ForegroundColor of a specific TextMessage without affecting anything else.  Would you be kind enough to provide guidance on how this can be accomplished?  My goal is to have the text for some authors displayed in different colors according to their respective roles.

Thanks so much!

Todd

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Nov 2018, 12:57 PM
Hello, Todd, 

The RadChat.ItemFormatting event can be used to access and change the styling of the message item elements. You can find below a sample code snippet demonstrating how to change the fore color of the messages of the other author in the conversation:

private void radChat1_ItemFormatting(object sender, ChatItemElementEventArgs e)
{
    TextMessageItemElement textMessage = e.ItemElement as TextMessageItemElement;
    if (textMessage != null && !e.ItemElement.IsOwnMessage)
    {
        e.ItemElement.ForeColor = Color.Red;
    }
    else
    {
        e.ItemElement.ResetValue(LightVisualElement.ForeColorProperty, Telerik.WinControls.ValueResetFlags.Local);
    }
}

Additional information about formatting the messages is available in the following help article: https://docs.telerik.com/devtools/winforms/chat/customizing-appearance/accessing-and-customizing-elements

I hope this information helps.

Regards,
Dess | Tech Support Engineer, Sr.
Progress TelerikRadChat for Winforms
Tags
Conversational UI, Chat
Asked by
Todd
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or