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

Creating a Dynamic Telerik.Reporting.Table

2 Answers 994 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Alessandro
Top achievements
Rank 1
Alessandro asked on 19 Jan 2012, 08:13 PM
Hi, how do I create a Telerik.Reporting.Table Dynamicaly?

So far I have:

Dim

 

panel1 As New Telerik.Reporting.Panel()

 

Dim Table1 As New Telerik.Reporting.Table

 

Table1.Location =

New Telerik.Reporting.Drawing.PointU(New Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Cm), New Telerik.Reporting.Drawing.Unit(15, Telerik.Reporting.Drawing.UnitType.Cm))

 

Table1.Size =

New Telerik.Reporting.Drawing.SizeU(New Telerik.Reporting.Drawing.Unit(23, Telerik.Reporting.Drawing.UnitType.Cm), New Telerik.Reporting.Drawing.Unit(10, Telerik.Reporting.Drawing.UnitType.Cm))

 


Table1.DataSource = ADatasource

 

panel1.Location =

New Telerik.Reporting.Drawing.PointU(New Telerik.Reporting.Drawing.Unit(0,
Telerik.Reporting.Drawing.UnitType.Cm),
New Telerik.Reporting.Drawing.Unit(1, Telerik.Reporting.Drawing.UnitType.Cm))

 

panel1.Size =

New Telerik.Reporting.Drawing.SizeU(New Telerik.Reporting.Drawing.Unit(21, Telerik.Reporting.Drawing.UnitType.Cm), New Telerik.Reporting.Drawing.Unit(21, Telerik.Reporting.Drawing.UnitType.Cm))

 

panel1.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid

 

 

panel1.Items.Add(Table1)

 

Report3.Items.Add(panel1)

 

ReportViewer1.Report = Report3



but the table doesnt show , any help please?

2 Answers, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 21 Jan 2012, 01:59 PM
Hello Alessandro,

The best way to learn how to create a table programmatically would be to create one in the designer first and then go and examine the auto-generated code inside the InitializeComponent() method (it is in the Report.Designer.cs file). Check the following forum thread discussing the creation of dynamic tables.

Why doesn't your table show:
  1. The Table needs to have column groups and row groups defined (at least one of each)
  2. The table body needs columns and rows defined (as much as the corresponding groups)
  3. Each cell of the table must have an item inside of it (textbox, panel, etc...)
All the best,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
endbil
Top achievements
Rank 1
answered on 28 Jan 2014, 08:49 AM
Hi, how do I create a Telerik.Reporting.Table Dynamicaly?

my code:

            Telerik.Reporting.TextBox txt1 = new Telerik.Reporting.TextBox();
            Telerik.Reporting.TextBox txt2 = new Telerik.Reporting.TextBox();
            Telerik.Reporting.TextBox txt3 = new Telerik.Reporting.TextBox();
            Telerik.Reporting.TextBox txt4 = new Telerik.Reporting.TextBox();
            Telerik.Reporting.TextBox txt5 = new Telerik.Reporting.TextBox();
            Telerik.Reporting.TextBox txt6 = new Telerik.Reporting.TextBox();
            Telerik.Reporting.TextBox txtBaslik2 = new Telerik.Reporting.TextBox();
            Telerik.Reporting.Table table2 = new Telerik.Reporting.Table();
            table2.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(Telerik.Reporting.Drawing.Unit.Cm(4.9999327659606934D)));
            table2.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(Telerik.Reporting.Drawing.Unit.Cm(4.9999327659606934D)));
            table2.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(Telerik.Reporting.Drawing.Unit.Cm(4.9999327659606934D)));
            table2.Body.Rows.Add(new Telerik.Reporting.TableBodyRow(Telerik.Reporting.Drawing.Unit.Cm(1.2699999809265137D)));
            table2.Body.SetCellContent(0, 0, txt1);
            table2.Body.SetCellContent(0, 1, txt2);
            table2.Body.SetCellContent(0, 2, txt3);
            Telerik.Reporting.TableGroup tableGroup1 = new Telerik.Reporting.TableGroup();
            Telerik.Reporting.TableGroup tableGroup2 = new Telerik.Reporting.TableGroup();
            Telerik.Reporting.TableGroup tableGroup3 = new Telerik.Reporting.TableGroup();
            Telerik.Reporting.TableGroup tableGroup4 = new Telerik.Reporting.TableGroup();
            tableGroup1.Name = "tableGroup";
            tableGroup1.ReportItem = txtBaslik2;
            tableGroup2.Name = "tableGroup1";
            tableGroup2.ReportItem = txt5;
            tableGroup3.Name = "tableGroup2";
            tableGroup3.ReportItem = txt6;
            table2.ColumnGroups.Add(tableGroup1);
            table2.ColumnGroups.Add(tableGroup2);
            table2.ColumnGroups.Add(tableGroup3);
            table2.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
            txt1,
            txt2,
            txt3,
            txtBaslik2,
            txt5,
            txt6});
            table2.KeepTogether = false;
            table2.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Cm(0.30000147223472595D), Telerik.Reporting.Drawing.Unit.Cm(0.68562471866607666D));
            table2.Name = "table1";
            tableGroup4.Groupings.Add(new Telerik.Reporting.Grouping(null));
            tableGroup4.Name = "detailTableGroup";
            table2.RowGroups.Add(tableGroup4);
            table2.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Cm(14.999796867370606D), Telerik.Reporting.Drawing.Unit.Cm(1.8520833253860474D));
            table2.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid;
            table2.Style.BorderColor.Default = Color.Black;
            table2.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(1D, Telerik.Reporting.Drawing.UnitType.Pixel);
            table2.Style.LineStyle = Telerik.Reporting.Drawing.LineStyle.Solid;
            table2.Style.LineColor = Color.Black;
            table2.Style.LineWidth = new Telerik.Reporting.Drawing.Unit(1D, Telerik.Reporting.Drawing.UnitType.Pixel);    

 

but the table doesnt show , any help please?




Tags
General Discussions
Asked by
Alessandro
Top achievements
Rank 1
Answers by
Elian
Telerik team
endbil
Top achievements
Rank 1
Share this question
or