Click here to Skip to main content
12,351,655 members (36,600 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# C#4.0

I am doing code in C#.
I have created table using itextsharp, and binding my table with database,
so at every time i have no any idea about how many columns.
and i want my table in which column width is adjustable as par my data which is coming from database.

In below code ,if and only if, i know how much columns are their (in below case i.e 2 columns) so i used 2 width here ,
PdfPTable pdfTable = new PdfPTable(table.Columns.Count);
         iTextSharp.text.Rectangle rect = PageSize.LETTER;
               float pageWidth = rect.Width;
             if (pdfTable != null)
                         new float[] {
                        (float).15 * pageWidth ,
                         (float).15 * pageWidth,
                                      }, rect);

but when we have no any idea about number of columns(i.e when i binding pdfptable with my database) ,i can get count of columns , but how to set widths to each column widths as per data from database.
so plz help me..
Posted 26-Sep-11 19:38pm
Edited 27-Sep-11 23:01pm

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 1 Oct 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100