Progress® Telerik® Reporting R1 2021
New to Telerik Reporting? Download free 30-day trial
Create Report Items Programmatically
To create a report item in code, instantiate a report item object, set its properties, and add it to the Items collection of the section where you wish the control to appear. For example, this code will add two TextBox report items to a report:
Telerik.Reporting.Panel panel1 = new Telerik.Reporting.Panel(); Telerik.Reporting.TextBox textBox1 = new Telerik.Reporting.TextBox(); // panel1 panel1.Location = new Telerik.Reporting.Drawing.PointU(new Telerik.Reporting.Drawing.Unit(1.0, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(1.0, Telerik.Reporting.Drawing.UnitType.Cm)); panel1.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(8.5, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(3.5, Telerik.Reporting.Drawing.UnitType.Cm)); panel1.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid; // textBox1 textBox1.Location = new Telerik.Reporting.Drawing.PointU(new Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Cm)); textBox1.Name = "NameDataTextBox"; textBox1.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(5.0, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.6, Telerik.Reporting.Drawing.UnitType.Cm)); textBox1.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid; textBox1.StyleName = "Data"; textBox1.Value = "=Fields.CustomerID"; panel1.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {textBox1}); detail.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {panel1});