Class PdfGridCellCollection
- Namespace
- Syncfusion.Pdf.Grid
- Assembly
- Syncfusion.Pdf.Portable.dll
Provides access to an ordered, strongly typed collection of PdfGridCell objects.
public class PdfGridCellCollection : IEnumerable
- Inheritance
-
PdfGridCellCollection
- 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("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]
public int Count { get; }
Property Value
- int
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)
this[int]
Gets the PdfGridCell at the specified index.[Read-Only]
public PdfGridCell this[int index] { get; }
Parameters
index
int
Property Value
- 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.
public IEnumerator GetEnumerator()
Returns
- IEnumerator
An 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.
public int IndexOf(PdfGridCell cell)
Parameters
cell
PdfGridCellThe cell.
Returns
- int
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)