This is a migrated thread and some comments may be shown as answers.

Dynamically add textboxes in telerik report group header section

3 Answers 158 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
saravana asked on 19 Oct 2016, 11:43 AM

I want to dynmically add the text box in the Group header section. pls kindly help it is urgent i tried a code it not work.

 private void groupHeaderSection_ItemDataBinding(object sender, EventArgs e)

 Telerik.Reporting.TextBox Txtbox;
  Telerik.Reporting.TextBox TxtboxHead;        

                TxtboxHead = new Telerik.Reporting.TextBox();
                TxtboxHead.Value = "StartDt";
                TxtboxHead.Name = "txtHeadProdStartDt";
                TxtboxHead.Visible = true;

             Txtbox = new Telerik.Reporting.TextBox();
                Txtbox.Value = "12-Jan-2016 10:20 PM"
                Txtbox.Name = "txtFldProdStartDt";
                Txtbox.Visible = true;

  this.groupHeaderSection.Items.AddRange(new ReportItem[] { TxtboxHead, Txtbox});


It not disply any Control in Group Header section. but i debug it shows groupHeaderSection had 2 items TxtboxHead and txtbox pls help 

3 Answers, 1 is accepted

Sort by
Top achievements
Rank 1
answered on 19 Oct 2016, 11:48 AM

i also need add many textboxes based on condition i display some of them. and i need to display as tis format

Startdate         12-Jan-2016           vehicle type     Diesel          vehicel make year   2012 

vehicle Name   Maruti                    Mileage            2kms           Air condtion              no

Vehicle No        Z4003                   Closed Kms      1512 kms    

Top achievements
Rank 1
answered on 19 Oct 2016, 11:51 AM

i need to add some text boxes in the header sections. display some of them.

the desired format is

startdate        01-Feb-2016      vehicle Name      Maruti

Vehicleno       Z4000                 Air Condtion       No

vehicle year   2012                  closed kms         1812

Telerik team
answered on 24 Oct 2016, 09:30 AM
Hello saravana,

As of R3 2016, changes in the report template cannot be applied in report events - R3 2016 Upgrade Path. You can create an instance of the report and modify it before displaying it in a viewer.
For example:
var reportInstance = new MyVSReport();//or you can get a Telerik.Reporting.Report object here
//get a section or item you want to modify
var detail = reportInstance.items.Find("detail",true)[0] as Telerik.Reporting.DetailSection;
//generate items dynamically
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});
//display the modified report
var IRS = ne w InstanceReportSource {ReportDocument = reportInstance};
reportViewer1.ReportSource = IRS;

I hope this helps.

Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
General Discussions
Asked by
Top achievements
Rank 1
Answers by
Top achievements
Rank 1
Telerik team
Share this question