Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created June 6, 2024 13:34
Show Gist options
  • Save bjoerntx/48a7bf0d88cdd2dc09a04d6cc4c60096 to your computer and use it in GitHub Desktop.
Save bjoerntx/48a7bf0d88cdd2dc09a04d6cc4c60096 to your computer and use it in GitHub Desktop.
private static void ReplaceWithMergeField(ServerTextControl textControl, FieldInfo field)
{
textControl.Select(field.StartIndex, field.EndIndex - field.StartIndex);
var selectionText = textControl.Selection.Text;
var mergeField = new MergeField
{
Name = field.FieldName,
Text = selectionText,
ApplicationField =
{
DoubledInputPosition = true,
HighlightMode = HighlightMode.Activated
}
};
textControl.Selection.Text = string.Empty;
textControl.ApplicationFields.Add(mergeField.ApplicationField);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment