PdfGridColumnCollection Class
Provides access to an ordered, strongly typed collection of PdfGridColumn objects.
Inheritance
System.Object
PdfGridColumnCollection
Implements
System.Collections.IEnumerable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Syncfusion.Pdf.Grid
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfGridColumnCollection : IEnumerable
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.
Declaration
public PdfGridColumnCollection(PdfGrid grid)
Parameters
Type | Name | Description |
---|---|---|
PdfGrid | grid | The parent grid. |
Properties
Count
Gets the number of columns in the PdfGrid.[Read-Only]
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | 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)
Item[Int32]
Gets the PdfGridColumn at the specified index.[Read-Only]
Declaration
public PdfGridColumn this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type |
---|
PdfGridColumn |
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.
Declaration
public PdfGridColumn Add()
Returns
Type | Description |
---|---|
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.
Declaration
public void Add(PdfGridColumn column)
Parameters
Type | Name | Description |
---|---|---|
PdfGridColumn | column | The 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(Int32)
Adds the number of specified count.
Declaration
public void Add(int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | count | The 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.
Declaration
public IEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | An System.Collections.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)
Implements
System.Collections.IEnumerable