Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active May 16, 2018 15:10
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/47d0c082fb2ef4461afe29d8bc822ae7 to your computer and use it in GitHub Desktop.
Save bjoerntx/47d0c082fb2ef4461afe29d8bc822ae7 to your computer and use it in GitHub Desktop.
private void mailMerge_FieldMerged(object sender, MailMerge.FieldMergedEventArgs e)
{
if (e.TableCell == null)
return;
if (e.MailMergeFieldAdapter.TypeName == MergeField.TYPE_NAME)
{
MergeField mergeField = e.MailMergeFieldAdapter as MergeField;
Color cellColor;
int value;
if (int.TryParse(mergeField.Text, out value) == true)
{
if (value >= 700)
cellColor = Color.Red;
else if (value >= 600)
cellColor = Color.Orange;
else if (value >= 500)
cellColor = Color.Yellow;
else if (value >= 400)
cellColor = Color.Green;
else if (value >= 300)
cellColor = Color.Blue;
else if (value >= 200)
cellColor = Color.Indigo;
else if (value >= 100)
cellColor = Color.Violet;
else
cellColor = e.TableCell.CellFormat.BackColor;
e.TableCell.CellFormat.BackColor = cellColor;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment