From 0ae4ab86b789577e0f509e4bae246e831d62a053 Mon Sep 17 00:00:00 2001 From: KB Bot Date: Tue, 7 Oct 2025 12:05:49 +0000 Subject: [PATCH 1/2] Added new kb article chat-insert-message-specific-index --- .../chat-insert-message-specific-index.md | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 knowledge-base/chat-insert-message-specific-index.md diff --git a/knowledge-base/chat-insert-message-specific-index.md b/knowledge-base/chat-insert-message-specific-index.md new file mode 100644 index 000000000..9a3707831 --- /dev/null +++ b/knowledge-base/chat-insert-message-specific-index.md @@ -0,0 +1,49 @@ +--- +title: Inserting a Message at a Specific Index in RadChat +description: Learn how to insert a message at a specific index in the RadChat control in UI for WinForms. This guide explains how to utilize the `Insert` method with a `BaseChatDataItem`. +type: how-to +page_title: How to Insert a Message at a Specific Index in RadChat Control +meta_title: How to Insert a Message at a Specific Index in RadChat Control +slug: chat-insert-message-specific-index +tags: chat, ui-for-winforms, insert-message, basechatdataitem, messagesviewelement +res_type: kb +ticketid: 1694976 +--- + +## Environment + +|Product Version|Product|Author| +|----|----|----| +|2025.3.812|RadGridView for WinForms|[Dinko Krastev](https://www.telerik.com/blogs/author/dinko-krastev)| + +## Description + +In this tutorial, we will demonstrate how to insert a new message at a specific index in the RadChat control. + +## Solution + +To insert a message at a specific index in RadChat, use the `Insert()` method with a `BaseChatDataItem`. Follow these steps: + +1. Access the existing messages in RadChat using the `MessagesViewElement.Items` collection. +2. Create a `ChatMediaMessage` or another appropriate message type. +3. Convert the message into a `BaseChatDataItem` using the `ChatFactory.CreateDataItem()` method. +4. Use the `Insert()` method to place the new message at a specific index. + +Here is an example: + +````C# + +private void InsertMediaMessageAtBeginning() +{ + ChatMediaMessage mediaMessage = new ChatMediaMessage(Properties.Resources.AndrewFuller, new Size(300, 200), null, this.radChat1.Author, DateTime.Now); + BaseChatDataItem baseChatDataItem = this.radChat1.ChatElement.ChatFactory.CreateDataItem(mediaMessage); + this.radChat1.ChatElement.MessagesViewElement.Items.Insert(0, baseChatDataItem); +} + +```` + +## See Also + +* [RadChat Documentation](https://docs.telerik.com/devtools/winforms/controls/chat/overview) + +* [RadChat Messages](https://docs.telerik.com/devtools/winforms/controls/chat/chat-items/messages) From 897cd33b6a6accfb88f9f13d69026c943931d0d8 Mon Sep 17 00:00:00 2001 From: Dinko Krastev Date: Tue, 7 Oct 2025 15:14:28 +0300 Subject: [PATCH 2/2] Update chat-insert-message-specific-index.md --- knowledge-base/chat-insert-message-specific-index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knowledge-base/chat-insert-message-specific-index.md b/knowledge-base/chat-insert-message-specific-index.md index 9a3707831..211ec99b2 100644 --- a/knowledge-base/chat-insert-message-specific-index.md +++ b/knowledge-base/chat-insert-message-specific-index.md @@ -14,7 +14,7 @@ ticketid: 1694976 |Product Version|Product|Author| |----|----|----| -|2025.3.812|RadGridView for WinForms|[Dinko Krastev](https://www.telerik.com/blogs/author/dinko-krastev)| +|2025.3.812|RadChat for WinForms|[Dinko Krastev](https://www.telerik.com/blogs/author/dinko-krastev)| ## Description