How do I hide empty fields in a mailing label report?
I have a simple mailing label report of property owners with fields like OwnerName1, OwnerName2, etc. All properties have data in the OwnerName1 field but not all properties have data in the OwnerName2 field. I want my mailing labels to 'roll up' or hide the OwnerName2 field on the label if there is no data. Is this do-able? Any help would be appreciated.
0
-
Hi Erick,
I'm so glad you asked! Not only is this do-able, but I've done it! Eight years ago.
I created a template for Avery 5160 labels, which are 1" tall and 2.5" wide. Each label has five TextBox controls that may or may not have data in them.
The bottom four controls have their CanShrink property set to "True". If they're empty, they will shrink and the controls below will move up.
To scale the font size I had to use the RPX script to determine how big the font should be. The section Detail1 was renamed to MailingLabelDetail in my report, so this will likely need some tweaking to work in your own report(s):public void MailingLabelDetail_Format() { int visibleLines = 0; // visit all of the controls to see who has data foreach (ARControl control in rpt.Sections["MailingLabelDetail"].Controls) { if (control is TextBox) { TextBox text = (TextBox)control; if (text.Text != "") { visibleLines++; } } } // visibleLines is now the count of how many lines have data. Use it to determine // how big to make the font // a convenient function, perhaps replace with a case/switch or better // way to decide how big to make font int fontsize = 23 - 3 * visibleLines; // 3 -> 14, 4 -> 11, 5 -> 8 // visit controls again to set the font size, preserve font name and style foreach (ARControl control in rpt.Sections["MailingLabelDetail"].Controls) { if (control is TextBox) { TextBox text = (TextBox)control; if (text.Text != "") { text.Font = new System.Drawing.Font(text.Font.Name, fontsize, text.Font.Style); } } } }I hope this helps!
Regards,
-Malcolm0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
1 Kommentar