Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active June 6, 2019 15:39
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/4a4ff119bf306023e2077a484491251a to your computer and use it in GitHub Desktop.
Save bjoerntx/4a4ff119bf306023e2077a484491251a 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