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

Too many merge fields to display properly

1 Answer 63 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Kenneth
Top achievements
Rank 2
Iron
Kenneth asked on 31 Aug 2014, 04:42 PM
I have 86 merge fields, so when I click on the RibbonUI's  'Insert Merge Field ' button it displays a list of my fields and it runs off the bottom of the browser window.  There is no scroll bar or any way to scroll through the list of available merge fields.

My only alternative if this is the behavior would be to take over the command and display my own list, then have code insert the merge filed at the current caret position.

Is there a way to allow the user to scroll through this list?

1 Answer, 1 is accepted

Sort by
0
Accepted
Petya
Telerik team
answered on 03 Sep 2014, 03:00 PM
Hello Kenneth,

There is no way to show a scroll in the drop-down when the amount of fields is larger. You could modify the behavior however, all you need to do is remove the command binding and handle the button's Click event. The default implementation looks like this and you can modify it in any way you see fit.
private void AddMergeFieldsInDropDownContent(RadRibbonDropDownButton radRibbonDropDownButton)
{
    StackPanel stackPanel = new StackPanel();
 
    foreach (string fieldName in this.radRichTextBox.Document.MailMergeDataSource.GetColumnNames())
    {
        RadRibbonButton fieldButton = new RadRibbonButton()
        {
            Text = fieldName,
            Size = ButtonSize.Medium,
            HorizontalAlignment = HorizontalAlignment.Stretch,
            HorizontalContentAlignment = HorizontalAlignment.Left
        };
 
        fieldButton.Command = this.radRichTextBox.Commands.InsertFieldCommand;
        fieldButton.CommandParameter = new MergeField() { PropertyPath = fieldName };
 
        stackPanel.Children.Add(fieldButton);
    }
 
    stackPanel.Width = 140;
    radRibbonDropDownButton.DropDownContent = stackPanel;
}
 
private void insertMergeFieldButton_Click(object sender, RoutedEventArgs e)
{
    AddMergeFieldsInDropDownContent(sender as RadRibbonDropDownButton);
}


I hope this is useful.

Regards,
Petya
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
RichTextBox
Asked by
Kenneth
Top achievements
Rank 2
Iron
Answers by
Petya
Telerik team
Share this question
or