Class PdfGridCellCollection
Provides access to an ordered, strongly typed collection of PdfGridCell objects.
Inheritance
System.Object
PdfGridCellCollection
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 PdfGridCellCollection : 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("EmpDetails");
//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;
//Get grid cells for the particular row.
PdfGridCellCollection collection = pdfGrid.Rows[0].Cells;
//Get cells count.
int count = collection.Count;
//Get cell
PdfGridCell cell = collection[0];
//Set cell style.
cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
//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("EmpDetails")
'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
'Get grid cells for the particular row.
Dim collection As PdfGridCellCollection = pdfGrid.Rows(0).Cells
'Get cells count.
Dim count As Integer = collection.Count
'Get cell
Dim cell As PdfGridCell = collection(0)
'Set cell style.
cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
'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)
Properties
Count
Gets the cells count.[Read-Only]
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The count representing the number of cells present in a Row. |
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("EmpDetails");
//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;
//Get grid cells for the particular row.
PdfGridCellCollection collection = pdfGrid.Rows[0].Cells;
//Get cells count.
int count = collection.Count;
//Get cell
PdfGridCell cell = collection[0];
//Set cell style.
cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
//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("EmpDetails")
'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
'Get grid cells for the particular row.
Dim collection As PdfGridCellCollection = pdfGrid.Rows(0).Cells
'Get cells count.
Dim count As Integer = collection.Count
'Get cell
Dim cell As PdfGridCell = collection(0)
'Set cell style.
cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
'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 PdfGridCell at the specified index.[Read-Only]
Declaration
public PdfGridCell this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type | Description |
---|---|
PdfGridCell | The index of the required PdfGridCell |
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("EmpDetails");
//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;
//Get grid cells for the particular row.
PdfGridCellCollection collection = pdfGrid.Rows[0].Cells;
//Get cells count.
int count = collection.Count;
//Get cell
PdfGridCell cell = collection[0];
//Set cell style.
cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
//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("EmpDetails")
'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
'Get grid cells for the particular row.
Dim collection As PdfGridCellCollection = pdfGrid.Rows(0).Cells
'Get cells count.
Dim count As Integer = collection.Count
'Get cell
Dim cell As PdfGridCell = collection(0)
'Set cell style.
cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
'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
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 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("EmpDetails");
//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;
//Get grid cells for the particular row.
PdfGridCellCollection collection = pdfGrid.Rows[0].Cells;
//custom collection enumerator.
foreach (PdfGridCell cell in collection)
{
cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
}
//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("EmpDetails")
'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
'Get grid cells for the particular row.
Dim collection As PdfGridCellCollection = pdfGrid.Rows(0).Cells
'custom collection enumerator.
For Each cell As PdfGridCell In collection
cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
Next
'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)
IndexOf(PdfGridCell)
Returns the index of a particular cell in the collection.
Declaration
public int IndexOf(PdfGridCell cell)
Parameters
Type | Name | Description |
---|---|---|
PdfGridCell | cell | The cell. |
Returns
Type | Description |
---|---|
System.Int32 | Index of the particular cell. |
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("EmpDetails");
//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;
//Get grid cells for the particular row.
PdfGridCellCollection collection = pdfGrid.Rows[0].Cells;
//Get cells count.
int count = collection.Count;
//Get cell
PdfGridCell cell = collection[0];
//Set cell style.
cell.Style.BackgroundImage = new PdfBitmap("Autumn leaves.jpg");
//Get the index of the cell.
int index = collection.IndexOf(cell);
//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("EmpDetails")
'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
'Get grid cells for the particular row.
Dim collection As PdfGridCellCollection = pdfGrid.Rows(0).Cells
'Get cells count.
Dim count As Integer = collection.Count
'Get cell
Dim cell As PdfGridCell = collection(0)
'Set cell style.
cell.Style.BackgroundImage = New PdfBitmap("Autumn leaves.jpg")
'Get the index of the cell.
Dim index As Integer = collection.IndexOf(cell)
'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)
Implements
System.Collections.IEnumerable