Im trying to figure out how you go about figuring out where to place the next element on the form.
If I have 2 tables on the page (dynamically populated, rows will very so height will very), table 1 has a height of 200 and table 2 has a height of 200 with 50y of white space in between. That being said the next element needs to be positioned at 500y.
How can you determine where to place the next object on the page?
Do you need to keep track of the heights of your elements as well as the spacing and use that variable to set the y for the next element?
Position Of Next Element
Re: Position Of Next Element
Support · Oct 8, 2007Hello,
Yes, you will have to keep track of the Y position to add a new element. You can get the height of the table by using the GetRequiredHeight method of the table object and you can add some padding to this height to add a new element. Following is the sample code for this.
Document document = new Document();
Page page = new Page();
Table table = new Table(10, 10, 100, 0);
table.Columns.Add(50);
table.Columns.Add(50);
for(int i=0; i<5; i++)
{
Row row = table.Rows.Add(20);
row.Cells.Add(i.ToString());
row.Cells.Add(i.ToString());
}
table.Height = table.GetRequiredHeight();
page.Elements.Add(table);
float Y = table.GetRequiredHeight() + 50;
Label label = new Label("dynamically added label", 10, Y, 300, 20);
page.Elements.Add(label);
document.Pages.Add(page);
document.DrawToWeb();
Thanks,
ceTe Software Support Team.