Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active October 8, 2020 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/16222de73bca7988b29b807dcb2c311f to your computer and use it in GitHub Desktop.
Save bjoerntx/16222de73bca7988b29b807dcb2c311f to your computer and use it in GitHub Desktop.
private void MailMerge_FieldMerged(object sender,
TXTextControl.DocumentServer.MailMerge.FieldMergedEventArgs e)
{
// custom field handling
if (e.TableCell == null)
return;
// if TableCell.Name has instructions, create a CellFilterInstructions object
// and evaluate the instructions and set the table cell color
if (e.TableCell.Name != "")
{
CellFilterInstructions instructions =
(CellFilterInstructions)JsonConvert.DeserializeObject(
e.TableCell.Name, typeof(CellFilterInstructions));
// retrieve the color
Color? color = instructions.GetColor(e.MailMergeFieldAdapter.ApplicationField.Text);
// apply the color
if (color != null)
e.TableCell.CellFormat.BackColor = (Color)color;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment