Class PdfGridEndCellLayoutEventArgs
Represents arguments of EndCellLayout Event.
Inherited Members
Namespace: Syncfusion.Pdf.Grid
Assembly: Syncfusion.Pdf.NET.dll
Syntax
public class PdfGridEndCellLayoutEventArgs : GridCellLayoutEventArgs
Examples
// Creates a new document
PdfDocument doc = new PdfDocument();
RectangleF rect = new RectangleF(0, 0, 500, 50);
//Create DataTable for source
DataTable dataTable = new DataTable("myTable");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Roll Number", "Student Name" };
dataTable.Rows.Add(values);
values = new object[] { "011", "Cris" };
dataTable.Rows.Add(values);
values = new object[] { "011", "Clay" };
dataTable.Rows.Add(values);
PdfPage page = doc.Pages.Add();
PdfPageTemplateElement top = new PdfPageTemplateElement(rect);
PdfGrid table = new PdfGrid();
// Subscribe the cell layout event
table.EndCellLayout += new PdfGridEndCellLayoutEventHandler(table_EndCellLayout);
table.DataSource = dataTable;
// Draws the table in page
table.Draw(page.Graphics);
doc.Save("Tables.pdf");
// Cell layout event handler
void table_EndCellLayout(object sender, PdfGridEndCellLayoutEventArgs args)
{
if (args.RowIndex == 1)
{
args.Graphics.DrawRectangle(new PdfPen(PdfBrushes.Red, 2), PdfBrushes.White, args.Bounds);
}
}
' Creates a new document
Dim doc As PdfDocument = New PdfDocument()
Dim rect As RectangleF = New RectangleF(0, 0, 500, 50)
'Create DataTable for source
Dim dataTable As DataTable = New DataTable("myTable")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = New Object() { "Roll Number", "Student Name" }
dataTable.Rows.Add(values)
values = New Object() { "011", "Cris" }
dataTable.Rows.Add(values)
values = New Object() { "011", "Clay" }
dataTable.Rows.Add(values)
Dim page As PdfPage = doc.Pages.Add()
Dim top As PdfPageTemplateElement = New PdfPageTemplateElement(rect)
Dim table As PdfGrid = New PdfGrid()
' Subscribe the cell layout event
AddHandler table.EndCellLayout, AddressOf table_EndCellLayout
table.DataSource = dataTable
table.Style.CellPadding = 16
' Draws the table in page
table.Draw(page.Graphics)
doc.Save("Tables.pdf")
' Cell layout event handler
Private Sub table_EndCellLayout(ByVal sender As Object, ByVal args As PdfGridEndCellLayoutEventArgs)
If args.RowIndex = 1 Then
args.Graphics.DrawRectangle(New PdfPen(PdfBrushes.Red, 2), PdfBrushes.White, args.Bounds)
End If
End Sub
Properties
Style
Get the PdfGridCellStyle
Declaration
public PdfGridCellStyle Style { get; }
Property Value
Type |
---|
PdfGridCellStyle |
Examples
// Creates a new document
PdfDocument doc = new PdfDocument();
RectangleF rect = new RectangleF(0, 0, 500, 50);
//Create DataTable for source
DataTable dataTable = new DataTable("myTable");
dataTable.Columns.Add("ID1");
dataTable.Columns[0].Caption = "id";
dataTable.Columns.Add("ID2");
object[] values = new object[] { "Roll Number", "Student Name" };
dataTable.Rows.Add(values);
values = new object[] { "011", "Cris" };
dataTable.Rows.Add(values);
values = new object[] { "011", "Clay" };
dataTable.Rows.Add(values);
PdfPage page = doc.Pages.Add();
PdfPageTemplateElement top = new PdfPageTemplateElement(rect);
PdfGrid table = new PdfGrid();
// Subscribe the cell layout event
table.EndCellLayout += new PdfGridEndCellLayoutEventHandler(table_EndCellLayout);
table.DataSource = dataTable;
// Draws the table in page
table.Draw(page.Graphics);
doc.Save("Tables.pdf");
// Cell layout event handler
void table_EndCellLayout(object sender, PdfGridEndCellLayoutEventArgs args)
{
if (args.RowIndex == 1)
{
args.Graphics.DrawRectangle(new PdfPen(PdfBrushes.Red, 2), PdfBrushes.White, args.Bounds);
}
}
' Creates a new document
Dim doc As PdfDocument = New PdfDocument()
Dim rect As RectangleF = New RectangleF(0, 0, 500, 50)
'Create DataTable for source
Dim dataTable As DataTable = New DataTable("myTable")
dataTable.Columns.Add("ID1")
dataTable.Columns(0).Caption = "id"
dataTable.Columns.Add("ID2")
Dim values() As Object = New Object() { "Roll Number", "Student Name" }
dataTable.Rows.Add(values)
values = New Object() { "011", "Cris" }
dataTable.Rows.Add(values)
values = New Object() { "011", "Clay" }
dataTable.Rows.Add(values)
Dim page As PdfPage = doc.Pages.Add()
Dim top As PdfPageTemplateElement = New PdfPageTemplateElement(rect)
Dim table As PdfGrid = New PdfGrid()
' Subscribe the cell layout event
AddHandler table.EndCellLayout, AddressOf table_EndCellLayout
table.DataSource = dataTable
table.Style.CellPadding = 16
' Draws the table in page
table.Draw(page.Graphics)
doc.Save("Tables.pdf")
' Cell layout event handler
Private Sub table_EndCellLayout(ByVal sender As Object, ByVal args As PdfGridEndCellLayoutEventArgs)
If args.RowIndex = 1 Then
args.Graphics.DrawRectangle(New PdfPen(PdfBrushes.Red, 2), PdfBrushes.White, args.Bounds)
End If
End Sub