Class PdfGridColumnCollection
- Namespace
- Syncfusion.Pdf.Grid
- Assembly
- Syncfusion.Pdf.Portable.dll
Provides access to an ordered, strongly typed collection of PdfGridColumn objects.
public class PdfGridColumnCollection : IEnumerable
- Inheritance
-
PdfGridColumnCollection
- Implements
- Inherited Members
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable();
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Using the Column collection
pdfGrid.Columns[0].Width = 100;
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable()
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() {"E01", "Clay"})
dataTable.Rows.Add(New Object() {"E02", "Thomas"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Using the Column collection
pdfGrid.Columns(0).Width = 100
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Constructors
PdfGridColumnCollection(PdfGrid)
Initializes a new instance of the PdfGridColumnCollection class with the parent grid.
public PdfGridColumnCollection(PdfGrid grid)
Parameters
grid
PdfGridThe parent grid.
Properties
Count
Gets the number of columns in the PdfGrid.[Read-Only]
public int Count { get; }
Property Value
- int
The count.
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable();
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Using the Column collection
pdfGrid.Columns[0].Width = 100;
//Get the columns count.
int count = pdfGrid.Columns.Count;
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable()
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() {"E01", "Clay"})
dataTable.Rows.Add(New Object() {"E02", "Thomas"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Using the Column collection
pdfGrid.Columns(0).Width = 100
'Get the columns count.
Dim count As Integer = pdfGrid.Columns.Count
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
this[int]
Gets the PdfGridColumn at the specified index.[Read-Only]
public PdfGridColumn this[int index] { get; }
Parameters
index
int
Property Value
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create a DataTable.
DataTable dataTable = new DataTable();
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable.
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
//Assign data source.
pdfGrid.DataSource = dataTable;
//Using the Column collection
pdfGrid.Columns[0].Width = 100;
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
//Save the document.
doc.Save("Output.pdf");
//close the document
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page.
Dim page As PdfPage = doc.Pages.Add()
'Create a PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create a DataTable.
Dim dataTable As New DataTable()
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
'Add rows to the DataTable.
dataTable.Rows.Add(New Object() {"E01", "Clay"})
dataTable.Rows.Add(New Object() {"E02", "Thomas"})
'Assign data source.
pdfGrid.DataSource = dataTable
'Using the Column collection
pdfGrid.Columns(0).Width = 100
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)
Methods
Add()
Add a new column to the PdfGrid.
public PdfGridColumn Add()
Returns
- PdfGridColumn
The added column
Examples
//Create a new PDF document.
PdfDocument pdfDocument = new PdfDocument();
PdfPage pdfPage = pdfDocument.Pages.Add();
//Create a new PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Add three columns.
pdfGrid.Columns.Add();
pdfGrid.Columns.Add();
pdfGrid.Columns.Add();
//Add header.
pdfGrid.Headers.Add(1);
PdfGridRow pdfGridHeader = pdfGrid.Headers[0];
pdfGridHeader.Cells[0].Value = "Employee ID";
pdfGridHeader.Cells[1].Value = "Employee Name";
pdfGridHeader.Cells[2].Value = "Salary";
//Add rows.
PdfGridRow pdfGridRow = pdfGrid.Rows.Add();
pdfGridRow.Cells[0].Value = "E01";
pdfGridRow.Cells[1].Value = "Clay";
pdfGridRow.Cells[2].Value = "$10,000";
//Draw the PdfGrid.
pdfGrid.Draw(pdfPage, PointF.Empty);
//Save the document.
pdfDocument.Save("Output.pdf");
//Close the document
pdfDocument.Close(true);
'Create a new PDF document.
Dim pdfDocument As New PdfDocument()
Dim pdfPage As PdfPage = pdfDocument.Pages.Add()
'Create a new PdfGrid.
Dim pdfGrid As New PdfGrid()
'Add three columns.
pdfGrid.Columns.Add()
pdfGrid.Columns.Add()
pdfGrid.Columns.Add()
'Add header.
pdfGrid.Headers.Add(1)
Dim pdfGridHeader As PdfGridRow = pdfGrid.Headers(0)
pdfGridHeader.Cells(0).Value = "Employee ID"
pdfGridHeader.Cells(1).Value = "Employee Name"
pdfGridHeader.Cells(2).Value = "Salary"
'Add rows.
Dim pdfGridRow As PdfGridRow = pdfGrid.Rows.Add()
pdfGridRow.Cells(0).Value = "E01"
pdfGridRow.Cells(1).Value = "Clay"
pdfGridRow.Cells(2).Value = "$10,000"
'Draw the PdfGrid.
pdfGrid.Draw(pdfPage, PointF.Empty)
'Save the document.
pdfDocument.Save("Output.pdf")
'Close the document
pdfDocument.Close(True)
Add(PdfGridColumn)
Adds the specified column.
public void Add(PdfGridColumn column)
Parameters
column
PdfGridColumnThe column.
Examples
//Create a new PDF document.
PdfDocument pdfDocument = new PdfDocument();
PdfPage pdfPage = pdfDocument.Pages.Add();
//Create a new PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Create PDF grid column.
PdfGridColumn column1 = new PdfGridColumn(pdfGrid);
column1.Width = 100;
PdfGridColumn column2 = new PdfGridColumn(pdfGrid);
column2.Width = 200;
PdfGridColumn column3 = new PdfGridColumn(pdfGrid);
column3.Width = 100;
//Add three columns.
pdfGrid.Columns.Add(column1);
pdfGrid.Columns.Add(column2);
pdfGrid.Columns.Add(column3);
//Add header.
pdfGrid.Headers.Add(1);
PdfGridRow pdfGridHeader = pdfGrid.Headers[0];
pdfGridHeader.Cells[0].Value = "Employee ID";
pdfGridHeader.Cells[1].Value = "Employee Name";
pdfGridHeader.Cells[2].Value = "Salary";
//Add rows.
PdfGridRow pdfGridRow = pdfGrid.Rows.Add();
pdfGridRow.Cells[0].Value = "E01";
pdfGridRow.Cells[1].Value = "Clay";
pdfGridRow.Cells[2].Value = "$10,000";
//Draw the PdfGrid.
pdfGrid.Draw(pdfPage, PointF.Empty);
//Save the document.
pdfDocument.Save("Output.pdf");
//Close the document
pdfDocument.Close(true);
'Create a new PDF document.
Dim pdfDocument As New PdfDocument()
Dim pdfPage As PdfPage = pdfDocument.Pages.Add()
'Create a new PdfGrid.
Dim pdfGrid As New PdfGrid()
'Create PDF grid column.
Dim column1 As New PdfGridColumn(pdfGrid)
column1.Width = 100
Dim column2 As New PdfGridColumn(pdfGrid)
column2.Width = 200
Dim column3 As New PdfGridColumn(pdfGrid)
column3.Width = 100
'Add three columns.
pdfGrid.Columns.Add(column1)
pdfGrid.Columns.Add(column2)
pdfGrid.Columns.Add(column3)
'Add header.
pdfGrid.Headers.Add(1)
Dim pdfGridHeader As PdfGridRow = pdfGrid.Headers(0)
pdfGridHeader.Cells(0).Value = "Employee ID"
pdfGridHeader.Cells(1).Value = "Employee Name"
pdfGridHeader.Cells(2).Value = "Salary"
'Add rows.
Dim pdfGridRow As PdfGridRow = pdfGrid.Rows.Add()
pdfGridRow.Cells(0).Value = "E01"
pdfGridRow.Cells(1).Value = "Clay"
pdfGridRow.Cells(2).Value = "$10,000"
'Draw the PdfGrid.
pdfGrid.Draw(pdfPage, PointF.Empty)
'Save the document.
pdfDocument.Save("Output.pdf")
'Close the document
pdfDocument.Close(True)
Add(int)
Adds the number of specified count.
public void Add(int count)
Parameters
count
intThe count.
Examples
//Create a new PDF document.
PdfDocument pdfDocument = new PdfDocument();
PdfPage pdfPage = pdfDocument.Pages.Add();
//Create a new PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Add three columns.
pdfGrid.Columns.Add(3);
//Add header.
pdfGrid.Headers.Add(1);
PdfGridRow pdfGridHeader = pdfGrid.Headers[0];
pdfGridHeader.Cells[0].Value = "Employee ID";
pdfGridHeader.Cells[1].Value = "Employee Name";
pdfGridHeader.Cells[2].Value = "Salary";
//Add rows.
PdfGridRow pdfGridRow = pdfGrid.Rows.Add();
pdfGridRow.Cells[0].Value = "E01";
pdfGridRow.Cells[1].Value = "Clay";
pdfGridRow.Cells[2].Value = "$10,000";
//Draw the PdfGrid.
pdfGrid.Draw(pdfPage, PointF.Empty);
//Save the document.
pdfDocument.Save("Output.pdf");
//Close the document
pdfDocument.Close(true);
'Create a new PDF document.
Dim pdfDocument As New PdfDocument()
Dim pdfPage As PdfPage = pdfDocument.Pages.Add()
'Create a new PdfGrid.
Dim pdfGrid As New PdfGrid()
'Add three columns.
pdfGrid.Columns.Add(3)
'Add header.
pdfGrid.Headers.Add(1)
Dim pdfGridHeader As PdfGridRow = pdfGrid.Headers(0)
pdfGridHeader.Cells(0).Value = "Employee ID"
pdfGridHeader.Cells(1).Value = "Employee Name"
pdfGridHeader.Cells(2).Value = "Salary"
'Add rows.
Dim pdfGridRow As PdfGridRow = pdfGrid.Rows.Add()
pdfGridRow.Cells(0).Value = "E01"
pdfGridRow.Cells(1).Value = "Clay"
pdfGridRow.Cells(2).Value = "$10,000"
'Draw the PdfGrid.
pdfGrid.Draw(pdfPage, PointF.Empty)
'Save the document.
pdfDocument.Save("Output.pdf")
'Close the document
pdfDocument.Close(True)
GetEnumerator()
Returns an enumerator that iterates through a collection.
public IEnumerator GetEnumerator()
Returns
- IEnumerator
An IEnumerator object that can be used to iterate through the collection.
Examples
//Create a new PDF document.
PdfDocument pdfDocument = new PdfDocument();
PdfPage pdfPage = pdfDocument.Pages.Add();
//Create a new PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Add three columns.
pdfGrid.Columns.Add(3);
foreach(PdfGridColumn column in pdfGrid.Columns)
{
//Set width.
column.Width = 150;
}
//Add header.
pdfGrid.Headers.Add(1);
PdfGridRow pdfGridHeader = pdfGrid.Headers[0];
pdfGridHeader.Cells[0].Value = "Employee ID";
pdfGridHeader.Cells[1].Value = "Employee Name";
pdfGridHeader.Cells[2].Value = "Salary";
//Add rows.
PdfGridRow pdfGridRow = pdfGrid.Rows.Add();
pdfGridRow.Cells[0].Value = "E01";
pdfGridRow.Cells[1].Value = "Clay";
pdfGridRow.Cells[2].Value = "$10,000";
//Draw the PdfGrid.
pdfGrid.Draw(pdfPage, PointF.Empty);
//Save the document.
pdfDocument.Save("Output.pdf");
//Close the document
pdfDocument.Close(true);
'Create a new PDF document.
Dim pdfDocument As New PdfDocument()
Dim pdfPage As PdfPage = pdfDocument.Pages.Add()
'Create a new PdfGrid.
Dim pdfGrid As New PdfGrid()
'Add three columns.
pdfGrid.Columns.Add(3)
For Each column As PdfGridColumn In pdfGrid.Columns
'Set width.
column.Width = 150
Next
'Add header.
pdfGrid.Headers.Add(1)
Dim pdfGridHeader As PdfGridRow = pdfGrid.Headers(0)
pdfGridHeader.Cells(0).Value = "Employee ID"
pdfGridHeader.Cells(1).Value = "Employee Name"
pdfGridHeader.Cells(2).Value = "Salary"
'Add rows.
Dim pdfGridRow As PdfGridRow = pdfGrid.Rows.Add()
pdfGridRow.Cells(0).Value = "E01"
pdfGridRow.Cells(1).Value = "Clay"
pdfGridRow.Cells(2).Value = "$10,000"
'Draw the PdfGrid.
pdfGrid.Draw(pdfPage, PointF.Empty)
'Save the document.
pdfDocument.Save("Output.pdf")
'Close the document
pdfDocument.Close(True)