Get List of Visible Rows from Table

Get List of Visible Rows from Table

Forum member · Dec 7, 2010
Good morning, I have a custom layout routine that calls for slightly more control than perhaps is usual. As a result, I have found that I need to be able to get a list of visible rows from a given table; however, the GetOverflowRows() method seems to return the entire set (both visible and invisible) while the GetVisibleRowCount() obviously just returns the number of visible rows. Is there any way to find out *which* rows are visible? I can't seem to even find a property on the Row2 object that would point in the right direction. Thanks for your help, Evan

Re: Get List of Visible Rows from Table

Support · Dec 7, 2010
Hello, There is no direct method in our DynamicPDF Generator API which can return the visible row list but you can achieve your requirements by getting the visible row count of the table and then you can access the required row using the indexer. Below is the sample code for it. Document document = new Document(); Page page = new Page(); Table2 table = new Table2(0, 0, 600, 50); table.Border.Width = 1; table.CellDefault.Border.Width = 1; table.Columns.Add(100); table.Columns.Add(100); table.Columns.Add(100); for (int i = 0; i < 6; i++) { Row2 row1 = table.Rows.Add(20, Font.Courier, 12, Grayscale.Black, Grayscale.Gray); Cell2 cell = row1.Cells.Add("Cell text1"); cell.Splittable = true; Cell2 cell2 = row1.Cells.Add("Cell Text2"); cell2.Splittable = true; Cell2 cell3 = row1.Cells.Add("cell text3"); cell3.Splittable = true; } int count = table.GetVisibleRowCount(); for(int j=0;j<count;j++) { Console.WriteLine("Row cell1 text " + table.Rows[j].Cells[0].Text); Console.WriteLine("Row cell1 text " + table.Rows[j].Cells[1].Text); Console.WriteLine("Row cell1 text " + table.Rows[j].Cells[2].Text); } Console.ReadKey(); page.Elements.Add(table); document.Pages.Add(page); document.Draw(@"C:\MyDocument.pdf"); If the above suggestions do not meet your requirements then please send over more details about your requirements to our support team at: [^a|mailto:support@cete.com|opennewiwndow|support@cete.com^] so that they can look into it further.