or
public class MyObject{ public int ID { get; set; } public string Name { get; set;} public List<MySubObject> SubList { get; set; }}public class MySubObject{ public int ID { get; set; } public decimal Percentage { get; set; } public string SurveyGroupName { get; set;}}using System.Collections.Generic;using System.Data;using BE;namespace TimeRegisterClient{ using System; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; using Telerik.Reporting; using Telerik.Reporting.Drawing; /// <summary> /// Summary description for WeekReport. /// </summary> public partial class TidsRapport : Telerik.Reporting.Report { private void setEmptyRowStandard(Telerik.Reporting.TextBox RowBox) { RowBox.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point); RowBox.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point); RowBox.Value = ""; } private void setTotalRowStandard(Telerik.Reporting.TextBox RowBox) { RowBox.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point); RowBox.Style.BorderWidth.Top = new Telerik.Reporting.Drawing.Unit(1D, Telerik.Reporting.Drawing.UnitType.Point); RowBox.Style.BorderStyle.Top = BorderType.Solid; RowBox.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point); RowBox.Style.TextAlign = HorizontalAlign.Left; RowBox.Style.VerticalAlign = VerticalAlign.Middle; } private void setCustomerRowStandard(Telerik.Reporting.TextBox RowBox) { RowBox.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point); RowBox.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point); RowBox.Style.TextAlign = HorizontalAlign.Left; RowBox.Style.VerticalAlign = VerticalAlign.Middle; } private void setDayHeaderStandard(Telerik.Reporting.TextBox RowBox) { RowBox.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point); RowBox.Style.BorderWidth.Bottom = new Telerik.Reporting.Drawing.Unit(1D, Telerik.Reporting.Drawing.UnitType.Point); ; RowBox.Style.BorderStyle.Bottom = BorderType.Solid; RowBox.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point); RowBox.Style.VerticalAlign = VerticalAlign.Middle; } private void setColumnStandard(Telerik.Reporting.TextBox RowBox,Unit height) { RowBox.Style.Font.Underline = true; RowBox.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(14D, Telerik.Reporting.Drawing.UnitType.Point); RowBox.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point); RowBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; RowBox.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(2.4999997615814209D, Telerik.Reporting.Drawing.UnitType.Cm),height); } public TidsRapport(Dictionary<DayOfWeek, Dictionary<int, UpdCus>> values, UserDetail user, DateTime from, DateTime to) : this() { FromTime = from; ToTime = to; WriteDate(); TxtFraBruger.Value += user.Name; populatealmostlikeabaws(values); //uglypopulate(values); } #region new private void populatealmostlikeabaws(Dictionary<DayOfWeek, Dictionary<int, UpdCus>> values) { PointU l = new PointU( new Unit(0.299999862909317D, UnitType.Cm), new Unit(4.5999999046325684D, UnitType.Cm)); SizeU s = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(12.600000381469727D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(2.4000000953674316D, Telerik.Reporting.Drawing.UnitType.Cm)); ReportTableGenerator tg = new ReportTableGenerator(s, l, new Telerik.Reporting.Drawing.Unit(0.6D, Telerik.Reporting.Drawing.UnitType.Cm)); setColumnStandard(tg.Nextbox, tg.DefaultRowHeight); tg.Nextbox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Left; tg.Nextbox.Value = "Dag/Kunde"; tg.addColumn(new Telerik.Reporting.Drawing.Unit(10.09999942779541D, Telerik.Reporting.Drawing.UnitType.Cm)); setColumnStandard(tg.Nextbox, tg.DefaultRowHeight); tg.Nextbox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; tg.Nextbox.Value = "Tider"; tg.addColumn(new Telerik.Reporting.Drawing.Unit(2.4999997615814209D, Telerik.Reporting.Drawing.UnitType.Cm)); tg.DefaultRowHeight = new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm); Dictionary<int, UpdCus> total = new Dictionary<int, UpdCus>(); DayOfWeek DayOfWork = FromTime.DayOfWeek; for (int i = 0; i < (values.Keys.Count + 1); i++) { Boolean notlast = i < values.Keys.Count; setDayHeaderStandard(tg.Nextbox); tg.Nextbox.Style.TextAlign = HorizontalAlign.Left; tg.Nextbox.Style.Padding.Left = new Unit(1.5, UnitType.Cm); tg.Nextbox.Style.Font.Bold = true; if (notlast) tg.Nextbox.Value = DayOfWork.ToString(); else tg.Nextbox.Value = "Samlet tid"; tg.addRowCell(); setDayHeaderStandard(tg.Nextbox); tg.Nextbox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; tg.addRowCell(); tg.appendRow(); Decimal weekHours = 0; #region Customer Times loop Dictionary<int, UpdCus> temp; if (notlast) temp = values[DayOfWork]; else temp = total; foreach (UpdCus c in temp.Values) { if (notlast) { if (!total.ContainsKey(c.CustomerId)) { total.Add(c.CustomerId, c); } else { total[c.CustomerId].update.TimeSpent += c.update.TimeSpent; } } setCustomerRowStandard(tg.Nextbox); tg.Nextbox.Style.Padding.Left = new Unit(2.5, UnitType.Cm); tg.Nextbox.Value = c.CustomerName; tg.addRowCell(); setCustomerRowStandard(tg.Nextbox); tg.Nextbox.Value = c.update.TimeSpent.ToString(); tg.addRowCell(); tg.appendRow(); weekHours += c.update.TimeSpent; } #endregion #region Total Row add setTotalRowStandard(tg.Nextbox); tg.Nextbox.Style.Padding.Left = new Unit(2.5, UnitType.Cm); tg.Nextbox.Value = "total tid registreret " + (notlast ? DayOfWork + "" : "I alt"); tg.addRowCell(); setTotalRowStandard(tg.Nextbox); tg.Nextbox.Value = weekHours + ""; tg.addRowCell(); tg.appendRow(); #endregion #region empty row add if (notlast) { setEmptyRowStandard(tg.Nextbox); tg.addRowCell(); setEmptyRowStandard(tg.Nextbox); tg.addRowCell(); tg.appendRow(); } #endregion DayOfWork++; } tg.finishTable(); DetailSection.Items.Add(tg.table); } #endregion #region old private void uglypopulate(Dictionary<DayOfWeek, Dictionary<int, UpdCus>> values) { Telerik.Reporting.Table DataTable; List<Telerik.Reporting.ReportItemBase> tableItems = new List<ReportItemBase>(); Telerik.Reporting.TextBox FirstDay = new Telerik.Reporting.TextBox(); Telerik.Reporting.TextBox empty = new Telerik.Reporting.TextBox(); DataTable = new Telerik.Reporting.Table(); DetailSection.Items.Add(DataTable); Telerik.Reporting.TextBox TextHeader; Telerik.Reporting.TextBox HourHeader; Telerik.Reporting.TableGroup tableGroup1 = new Telerik.Reporting.TableGroup(); Telerik.Reporting.TableGroup tableGroup2 = new Telerik.Reporting.TableGroup(); Telerik.Reporting.TableGroup tableGroup3 = new Telerik.Reporting.TableGroup(); TextHeader = new Telerik.Reporting.TextBox(); HourHeader = new Telerik.Reporting.TextBox(); TextHeader = new Telerik.Reporting.TextBox(); HourHeader = new Telerik.Reporting.TextBox(); DataTable.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(new Telerik.Reporting.Drawing.Unit(10.09999942779541D, Telerik.Reporting.Drawing.UnitType.Cm))); DataTable.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(new Telerik.Reporting.Drawing.Unit(2.4999997615814209D, Telerik.Reporting.Drawing.UnitType.Cm))); DataTable.Body.Rows.Add(new Telerik.Reporting.TableBodyRow(new Telerik.Reporting.Drawing.Unit(0.6D, Telerik.Reporting.Drawing.UnitType.Cm))); DataTable.Body.SetCellContent(0, 0, FirstDay); DataTable.Body.SetCellContent(0, 1, empty); tableGroup1.ReportItem = TextHeader; tableGroup2.ReportItem = HourHeader; DataTable.ColumnGroups.Add(tableGroup1); DataTable.ColumnGroups.Add(tableGroup2); tableItems.AddRange(new Telerik.Reporting.ReportItemBase[] { FirstDay, empty, TextHeader, HourHeader}); DataTable.Location = new Telerik.Reporting.Drawing.PointU(new Telerik.Reporting.Drawing.Unit(0.299999862909317D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(4.5999999046325684D, Telerik.Reporting.Drawing.UnitType.Cm)); DataTable.Name = "DataTable"; DataTable.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(12.600000381469727D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(2.4000000953674316D, Telerik.Reporting.Drawing.UnitType.Cm)); TextHeader.Name = "TextHeader"; TextHeader.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(10.09999942779541D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.6D, Telerik.Reporting.Drawing.UnitType.Cm)); TextHeader.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point); TextHeader.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(14D, Telerik.Reporting.Drawing.UnitType.Point); TextHeader.Style.Font.Underline = true; TextHeader.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Left; TextHeader.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; TextHeader.Value = "Dag/Kunde"; HourHeader.Name = "HourHeader"; HourHeader.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(2.4999997615814209D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.6D, Telerik.Reporting.Drawing.UnitType.Cm)); HourHeader.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point); HourHeader.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(14D, Telerik.Reporting.Drawing.UnitType.Point); HourHeader.Style.Font.Underline = true; HourHeader.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; HourHeader.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; HourHeader.Value = "Tider"; Boolean made = true; int row = 1; Dictionary<int, UpdCus> total = new Dictionary<int, UpdCus>(); DayOfWeek DayOfWork = FromTime.DayOfWeek; for (int i = 0; i < (values.Keys.Count + 1); i++) { Boolean notlast = i < values.Keys.Count; if (made) { made = false; } else { DataTable.Body.Rows.Add(new Telerik.Reporting.TableBodyRow(new Telerik.Reporting.Drawing.Unit(0.6D, Telerik.Reporting.Drawing.UnitType.Cm))); FirstDay = new Telerik.Reporting.TextBox(); empty = new Telerik.Reporting.TextBox(); DataTable.Body.SetCellContent(row, 0, FirstDay); DataTable.Body.SetCellContent(row, 1, empty); row++; tableItems.AddRange(new Telerik.Reporting.ReportItemBase[] { FirstDay, empty}); } TableGroup t = new TableGroup(); tableGroup3.ChildGroups.Add(t); FirstDay.Name = DayOfWork.ToString(); //FirstDay.Size = new SizeU(new Unit(10.09999942779541D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.6D, Telerik.Reporting.Drawing.UnitType.Cm)); FirstDay.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point); FirstDay.Style.BorderWidth.Bottom = new Telerik.Reporting.Drawing.Unit(1D, Telerik.Reporting.Drawing.UnitType.Point); ; FirstDay.Style.BorderStyle.Bottom = BorderType.Solid; FirstDay.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point); FirstDay.Style.TextAlign = HorizontalAlign.Left; FirstDay.Style.VerticalAlign = VerticalAlign.Middle; FirstDay.Style.Padding.Left = new Unit(1.5, UnitType.Cm); FirstDay.Style.Font.Bold = true; if (notlast) FirstDay.Value = DayOfWork.ToString(); else FirstDay.Value = "Samlet tid"; // empty.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(2.4999997615814209D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.6D, Telerik.Reporting.Drawing.UnitType.Cm)); empty.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center; empty.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; empty.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point); empty.Style.BorderWidth.Bottom = new Telerik.Reporting.Drawing.Unit(1D, Telerik.Reporting.Drawing.UnitType.Point); empty.Style.BorderStyle.Bottom = BorderType.Solid; empty.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point); Decimal weekHours = 0; #region Customer Times loop Dictionary<int, UpdCus> temp; if (notlast) temp = values[DayOfWork]; else temp = total; foreach (UpdCus c in temp.Values) { if (notlast) { if (!total.ContainsKey(c.CustomerId)) { total.Add(c.CustomerId, c); } else { total[c.CustomerId].update.TimeSpent += c.update.TimeSpent; } } DataTable.Body.Rows.Add(new Telerik.Reporting.TableBodyRow(new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm))); Telerik.Reporting.TextBox Customer = new Telerik.Reporting.TextBox(); Telerik.Reporting.TextBox Time = new Telerik.Reporting.TextBox(); empty.Name = DayOfWork.ToString() + "e"; DataTable.Body.SetCellContent(row, 0, Customer); DataTable.Body.SetCellContent(row, 1, Time); row++; tableItems.AddRange(new Telerik.Reporting.ReportItemBase[] { Customer, Time}); TableGroup t1 = new TableGroup(); tableGroup3.ChildGroups.Add(t1); Customer.Name = DayOfWork.ToString() + c.CustomerName; // Customer.Size = new SizeU(new Unit(10.09999942779541D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm)); Customer.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point); Customer.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point); Customer.Style.Padding.Left = new Unit(2.5, UnitType.Cm); Customer.Style.TextAlign = HorizontalAlign.Left; Customer.Style.VerticalAlign = VerticalAlign.Middle; Customer.Value = c.CustomerName; //Console.WriteLine(c.CustomerName + ": " + c.update.TimeSpent); //TableGroup n = new TableGroup(); // n.Grouping.Add(c.CustomerName); // DataTable.RowGroups.Add(n); Time.Name = DayOfWork.ToString() + "T"; Time.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point); //Time.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(2.4999997615814209D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm)); Time.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Left; Time.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; Time.Value = c.update.TimeSpent.ToString(); weekHours += c.update.TimeSpent; } #endregion #region Total Row add DataTable.Body.Rows.Add(new Telerik.Reporting.TableBodyRow(new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm))); Telerik.Reporting.TextBox CustomerTotal = new Telerik.Reporting.TextBox(); Telerik.Reporting.TextBox TimeTotal = new Telerik.Reporting.TextBox(); empty.Name = DayOfWork.ToString() + "e"; DataTable.Body.SetCellContent(row, 0, CustomerTotal); DataTable.Body.SetCellContent(row, 1, TimeTotal); row++; tableItems.AddRange(new Telerik.Reporting.ReportItemBase[] { CustomerTotal, TimeTotal}); TableGroup t2 = new TableGroup(); tableGroup3.ChildGroups.Add(t2); CustomerTotal.Name = DayOfWork.ToString() + "TotalDescription" + notlast; //CustomerTotal.Size = new SizeU(new Unit(10.09999942779541D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm)); CustomerTotal.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point); CustomerTotal.Style.BorderWidth.Top = new Telerik.Reporting.Drawing.Unit(1D, Telerik.Reporting.Drawing.UnitType.Point); CustomerTotal.Style.BorderStyle.Top = BorderType.Solid; CustomerTotal.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point); CustomerTotal.Style.Padding.Left = new Unit(2.5, UnitType.Cm); CustomerTotal.Style.TextAlign = HorizontalAlign.Left; CustomerTotal.Style.VerticalAlign = VerticalAlign.Middle; CustomerTotal.Value = "total tid registreret " + (notlast ? DayOfWork + "" : "I alt"); TimeTotal.Name = DayOfWork.ToString() + "TotalTimeTotal" + notlast; //TimeTotal.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(2.4999997615814209D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm)); TimeTotal.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Left; TimeTotal.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle; TimeTotal.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point); TimeTotal.Style.BorderWidth.Top = new Telerik.Reporting.Drawing.Unit(1D, Telerik.Reporting.Drawing.UnitType.Point); TimeTotal.Style.BorderStyle.Top = BorderType.Solid; TimeTotal.Value = weekHours + ""; #endregion #region empty row add if (notlast) { DataTable.Body.Rows.Add(new Telerik.Reporting.TableBodyRow(new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm))); Telerik.Reporting.TextBox CustomerEmpty = new Telerik.Reporting.TextBox(); Telerik.Reporting.TextBox TimeEmpty = new Telerik.Reporting.TextBox(); empty.Name = DayOfWork.ToString() + "e"; DataTable.Body.SetCellContent(row, 0, CustomerEmpty); DataTable.Body.SetCellContent(row, 1, TimeEmpty); row++; tableItems.AddRange(new Telerik.Reporting.ReportItemBase[] { CustomerEmpty, TimeEmpty}); TableGroup t3 = new TableGroup(); tableGroup3.ChildGroups.Add(t3); CustomerEmpty.Name = DayOfWork.ToString() + "dEmpty"; // CustomerEmpty.Size = new SizeU(new Unit(10.09999942779541D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm)); CustomerEmpty.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point); CustomerEmpty.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point); CustomerEmpty.Style.Padding.Left = new Unit(2.5, UnitType.Cm); CustomerEmpty.Style.TextAlign = HorizontalAlign.Left; CustomerEmpty.Style.VerticalAlign = VerticalAlign.Bottom; CustomerEmpty.Value = ""; TimeEmpty.Name = DayOfWork.ToString() + "EmptyTime"; //TimeEmpty.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(2.4999997615814209D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm)); TimeEmpty.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Left; TimeEmpty.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Bottom; TimeEmpty.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point); TimeEmpty.Value = ""; } #endregion DayOfWork++; } DataTable.Items.AddRange(tableItems.ToArray()); DataTable.RowGroups.Add(tableGroup3); tableGroup3.Grouping.AddRange(new Telerik.Reporting.Data.Grouping[] { new Telerik.Reporting.Data.Grouping("")}); tableGroup3.Name = "DetailGroup"; } #endregion public TidsRapport() { InitializeComponent(); } private void WriteDate() { TitleTextBox.Value += FromTime.ToShortDateString() + " til " + ToTime; TitleTextBox.Width += TitleTextBox.Width + new Unit(8.0, UnitType.Cm); } protected DateTime FromTime { get; set; } protected DateTime ToTime { get; set; } }}using System;using System.Collections.Generic;using System.Drawing;using System.Linq;using System.Text;using Telerik.Reporting;using Telerik.Reporting.Data;using Telerik.Reporting.Drawing;namespace TimeRegisterClient{ class ReportTableGenerator { public int CurrentRow { get; private set; } public int CurrentColumn { get; private set; } public int MaxColumns { get; private set; } public TextBox Nextbox { get; set; } private List<TextBox> nextRow { get; set; } private Table GeneratedTable; public Table table { get { if (isFinished) return GeneratedTable; return null; } private set { GeneratedTable = value; } } public Boolean isFinished { get; private set; } public Boolean ColumnsSet { get; set; } private List<ReportItemBase> tableItems { get; set; } public Unit DefaultRowHeight { get; set; } public ReportTableGenerator(Unit colHeight) { ColumnsSet = false; CurrentColumn = 0; CurrentRow = 0; MaxColumns = 0; DefaultRowHeight = new TextBox().Size.Height; RowGroup = new TableGroup(); tableItems = new List<ReportItemBase>(); GeneratedTable = new Table(); //GeneratedTable.Body.Rows.Add(new TableBodyRow(colHeight)); resetRow(); resetBoxes(); GeneratedTable.Name = "GeneratedTable"; } public ReportTableGenerator( SizeU size,PointU location,Unit columnheight):this(columnheight) { setDimensions(size,location); } public void finishTable() { GeneratedTable.Items.AddRange(tableItems.ToArray()); GeneratedTable.RowGroups.Add(RowGroup); RowGroup.Grouping.AddRange(new Grouping[] { new Grouping("") }); RowGroup.Name = "DetailGroup"; isFinished = true; } private void resetRow() { nextRow=new List<TextBox>(); } public void resetBoxes() { Nextbox = new TextBox(); } public void setDimensions(SizeU size, PointU location) { GeneratedTable.Location = location; GeneratedTable.Size = size; } public void addRowCell() { nextRow.Add(Nextbox); resetBoxes(); } public void appendRow() { int dif = nextRow.Count - (MaxColumns+1); if (dif > 0) throw new Exception("you added " + dif + " more cells to a row than possible"); if (!ColumnsSet) { ColumnsSet = true; completeColumns(); } GeneratedTable.Body.Rows.Add(new TableBodyRow(DefaultRowHeight)); TableGroup newGroup = new TableGroup(); RowGroup.ChildGroups.Add(newGroup); foreach (TextBox t in nextRow) { if (t.Name.Equals("")) t.Name = CurrentRow + "," + CurrentColumn; addCell(t); } resetRow(); } private void addCell(TextBox t) { GeneratedTable.Body.SetCellContent(CurrentRow,CurrentColumn,t); iterateCell(); tableItems.Add(t); } public void addColumn(Unit Width) { if(ColumnsSet) throw new Exception("You cannot add anymore columns at the given time"); GeneratedTable.Body.Columns.Add(new TableBodyColumn(Width)); TableGroup cgroup = new TableGroup(); MaxColumns++; cgroup.ReportItem = Nextbox; GeneratedTable.ColumnGroups.Add(cgroup); addCell(Nextbox); resetBoxes(); } private void completeColumns() { MaxColumns--; iterateCell(); } private void iterateCell() { if (CurrentColumn >= MaxColumns) { CurrentColumn = 0; CurrentRow++; } else { CurrentColumn++; } } private TableGroup RowGroup { get; set; } }}PointU l = new PointU( new Unit(0.299999862909317D, UnitType.Cm), new Unit(4.5999999046325684D, UnitType.Cm)); SizeU s = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(12.600000381469727D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(2.4000000953674316D, Telerik.Reporting.Drawing.UnitType.Cm)); ReportTableGenerator rg = new ReportTableGenerator(s, l, new Telerik.Reporting.Drawing.Unit(0.6D, Telerik.Reporting.Drawing.UnitType.Cm)); rg.Nextbox.Value = "ctest1"; rg.addColumn(new Unit(0.6D, UnitType.Cm)); rg.Nextbox.Value = "ctest2"; rg.addColumn(new Unit(0.6D, UnitType.Cm)); rg.Nextbox.Value = "row1"; rg.addRowCell(); rg.Nextbox.Value = "row12"; rg.appendRow(); rg.finishTable(); DetailSection.Items.Add(rg.table);CREATE TABLE ThingColor(id int PRIMARY KEY,thing varchar(20),color varchar(5))INSERT INTO ThingColorVALUES (1, 'sky', 'blue'), (2, 'sun', 'yello');