Current filter:
                                You should refresh the page.
                                Support Center

                                How to check which control initiates creating extra empty pages after every page in a report

                                0

                                This example illustrates how to check which control in a report gets printed on a certain page

                                You must  log in  or  register  to leave comments
                                Select file
                                • Form1.cs
                                • Program.cs
                                • XtraReport1.cs
                                • XtraReport2.cs
                                Select language
                                • C#
                                • VB.NET
                                Select version
                                • v2013 vol 1.4 - v2013 vol 2.9
                                • v2012 vol 2.4 - v2012 vol 2.16
                                • v2009 vol 3.5 - v2012 vol 1.12
                                using System;
                                using System.Collections.Generic;
                                using System.ComponentModel;
                                using System.Data;
                                using System.Drawing;
                                using System.Text;
                                using System.Windows.Forms;
                                using DevExpress.XtraPrinting;
                                using DevExpress.XtraReports.UI;
                                using System.Collections;
                                
                                namespace WindowsApplication1 {
                                    public partial class Form1 : Form {
                                        public Form1() {
                                            InitializeComponent();
                                        }
                                
                                        private void button1_Click(object sender, EventArgs e) {
                                            XtraReport1 r = new XtraReport1();
                                            r.CreateDocument();
                                            ShowControlsOnPage(r, 2);
                                            //r.ShowPreviewDialog();
                                        }
                                
                                
                                        private void ShowControlsOnPage(XtraReport1 report, int pageNumber) {
                                            if(report.PrintingSystem.Document.PageCount >= pageNumber - 1) {
                                                IDictionary controls = GetControlsOnPage(report, pageNumber);
                                                ArrayList al = CopyToArrayList(controls);
                                
                                                XtraReport r= new XtraReport();
                                                r.DataSource = al;
                                                DetailBand db = new DetailBand();
                                                db.Height = 20;
                                                r.Bands.Add(db);
                                                XRLabel l = new XRLabel();
                                                l.DataBindings.Add("Text", null, "FullName");
                                                l.Location = new Point(0, 0);
                                                l.Size = new Size(500, 20);
                                                db.Controls.Add(l);
                                                ReportPrintTool tool = new ReportPrintTool(r);
                                                tool.ShowPreviewDialog();
                                            }
                                        }
                                
                                        private ArrayList CopyToArrayList(IDictionary controls) {
                                            ArrayList al = new ArrayList();
                                            foreach(DictionaryEntry obj in controls) {
                                                al.Add(obj.Value);
                                            }
                                            return al;
                                        }
                                
                                        private static IDictionary GetControlsOnPage(XtraReport1 r, int pageNumber) {
                                            IDictionary controls = new Hashtable();
                                            Page p = r.PrintingSystem.Document.Pages[pageNumber - 1];
                                            BrickEnumerator be = p.GetEnumerator();
                                            while(be.MoveNext()) {
                                                VisualBrick vb = be.Current as VisualBrick;
                                                MObject mo = new MObject(((XRControl)vb.BrickOwner).Name, ((XRControl)vb.BrickOwner).Report.ToString());
                                                if(!controls.Contains(mo.FullName))
                                                    controls.Add(mo.FullName, mo);
                                            }
                                            return controls;
                                        }
                                    }
                                
                                    class MObject {
                                        public MObject(string n, string r) { objname = n; reportName = r; }
                                
                                        string objname;
                                        public string ObjName {
                                            get { return objname; }
                                            set { objname = value; }
                                        }
                                        string reportName;
                                
                                        public string ReportName {
                                            get { return reportName; }
                                            set { reportName = value; }
                                        }
                                        public string FullName {
                                            get { return reportName + "." + objname; }
                                        }
                                
                                    }
                                }

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners