Working with Content Controls

This article shows some examples of how you can access a content control and modify their properties from the code. In general, the content controls are marked with annotations and you can manipulate them as such. Detailed information is available here: Manipulating Annotations

Get the content controls.

The content controls can be retrieved by using the GetAnnotationMarkersOfType method. This is demonstrated in the following example.

Example 1: Get all Content Controls

IEnumerable<Telerik.WinForms.Documents.Model.StructuredDocumentTags.SdtRangeStart> content_controls
    = this.radRichTextEditor1.Document.GetAnnotationMarkersOfType<Telerik.WinForms.Documents.Model.StructuredDocumentTags.SdtRangeStart>();
foreach (var item in content_controls)
{
    Console.WriteLine("Type: {0} ID:{1}", item.SdtProperties.Type, item.SdtProperties.ID);
}

Dim content_controls As IEnumerable(Of Telerik.WinForms.Documents.Model.StructuredDocumentTags.SdtRangeStart) =
    Me.RadRichTextEditor1.Document.GetAnnotationMarkersOfType(Of Telerik.WinForms.Documents.Model.StructuredDocumentTags.SdtRangeStart)()
For Each item In content_controls
    Console.WriteLine("Type: {0} ID:{1}", item.SdtProperties.Type, item.SdtProperties.ID)
Next

Set content controls properties.

This example shows how you can iterate the items and add an item to a existing ComboBox content control.

Example 2: Adding items to a ComboBox or a DropDownList

foreach (var item in content_controls)
{
    if (item.SdtProperties.Type== Telerik.WinForms.Documents.Model.StructuredDocumentTags.SdtType.ComboBox )
    {
        Telerik.WinForms.Documents.Model.StructuredDocumentTags.ComboBoxProperties properties = item.SdtProperties as ComboBoxProperties;
        Telerik.WinForms.Documents.Model.StructuredDocumentTags.StructuredDocumentTagProperties.ListItem newItem = 
            new Telerik.WinForms.Documents.Model.StructuredDocumentTags.StructuredDocumentTagProperties.ListItem();
        newItem.DisplayText = "New Item Text";
        properties.Items.Add(newItem);
    }
}

For Each item In content_controls
    If item.SdtProperties.Type = Telerik.WinForms.Documents.Model.StructuredDocumentTags.SdtType.ComboBox Then
        Dim properties As Telerik.WinForms.Documents.Model.StructuredDocumentTags.ComboBoxProperties = TryCast(item.SdtProperties, ComboBoxProperties)
        Dim newItem As New Telerik.WinForms.Documents.Model.StructuredDocumentTags.StructuredDocumentTagProperties.ListItem()
        newItem.DisplayText = "New Item Text"
        properties.Items.Add(newItem)
    End If
Next

See Also

In this article
Not finding the help you need? Improve this article