Table Object Dynamic in C#
Hello Everybody! I'm trying to draw a table no with Designer but code-behind using c#.
IT's possibile to have an example how to make a table dynamic no with designer ?
I'm tryng but at the end the Engine dosen't print it
I made a newTabke = new TableObject() -> connected to the Manual Build events with this code :
newTable.ManualBuild += new EventHandler(GenerateNewDynamicTable);
private void GenerateNewDynamicTable(object sender, EventArgs e)
{
TableObject newTable = sender as TableObject;
newTable.PrintRow(0);
newTable.PrintColumns();
foreach(var col in tabA.Columns)
{
newTable.PrintColumns();
}
newTable.PrintRow(1);
int z = 0 ;
foreach (DataColumn col in tabA.Columns)
{
newTable.PrintColumns();
}
foreach (DataRow row in tabA.Rows)
{ int i = 0 ;
newTable.PrintRow(2);
foreach (DataColumn col in tabA.Columns)
{
newTable.PrintColumns();
}
}
}
Comments
Hello!
For a TableObject created entirely using C# code-behind to appear in the final report, it is not enough simply to subscribe to ManualBuild; you must also:
Set the column widths (ColumnCount, col.Width) and row heights (RowCount, row. Height), and add the TableObject to Band.Objects (for example, to the DataBand without an unnecessary empty data source, or to PageTitle/ReportSummary).
In the ManualBuild handler, call tbl.PrintRow(r); tbl.PrintColumns(); for each row to be displayed:
var table = new TableObject { Name = ‘DynTable’, Bounds = new RectangleF(0, 0, 300, 90) }; table.ColumnCount = 3; table.RowCount = 3; band.Objects.Add(table); table.ManualBuild += (s, e) => { var t = (TableObject)s; for (int r = 0; r < 3; r++) { for (int c = 0; c < 3; c++) t[c, r].Text = $‘R{r + 1}C{c + 1}’; t.PrintRow(r); t.PrintColumns(); } };