Table of Contents

Class PdfGridStyleBase

Namespace
Syncfusion.Pdf.Grid
Assembly
Syncfusion.Pdf.Portable.dll

Base class for the grid style

public abstract class PdfGridStyleBase : ICloneable
Inheritance
PdfGridStyleBase
Implements
Derived
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;
//Adding grid style
PdfGridStyle gridStyle = new PdfGridStyle();
//Allow grid to overflow horizontally
gridStyle.AllowHorizontalOverflow = true;
//Set background brush.
gridStyle.BackgroundBrush = PdfBrushes.Pink;
//Adding cell spacing between cells
gridStyle.CellSpacing = 0.5F;
//Setting text pen for grid
gridStyle.TextBrush = PdfBrushes.Blue;
//Applying style to grid
pdfGrid.Style = gridStyle;
//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
'Adding grid style
Dim gridStyle As New PdfGridStyle()
'Allow grid to overflow horizontally
gridStyle.AllowHorizontalOverflow = True
'Set background brush.
gridStyle.BackgroundBrush = PdfBrushes.Pink
'Adding cell spacing between cells
gridStyle.CellSpacing = 0.5F
'Setting text pen for grid
gridStyle.TextBrush = PdfBrushes.Blue
'Applying style to grid
pdfGrid.Style = gridStyle
'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

PdfGridStyleBase()

protected PdfGridStyleBase()

Properties

BackgroundBrush

Gets or sets the background brush.

public PdfBrush BackgroundBrush { get; set; }

Property Value

PdfBrush

The background brush of the PdfGrid.

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;
//Adding grid style
PdfGridStyle gridStyle = new PdfGridStyle();
//Allow grid to overflow horizontally
gridStyle.AllowHorizontalOverflow = true;
//Set background brush.
gridStyle.BackgroundBrush = PdfBrushes.Pink;
//Adding cell spacing between cells
gridStyle.CellSpacing = 0.5F;
//Setting text pen for grid
gridStyle.TextBrush = PdfBrushes.Blue;
//Applying style to grid
pdfGrid.Style = gridStyle;
//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
'Adding grid style
Dim gridStyle As New PdfGridStyle()
'Allow grid to overflow horizontally
gridStyle.AllowHorizontalOverflow = True
'Set background brush.
gridStyle.BackgroundBrush = PdfBrushes.Pink
'Adding cell spacing between cells
gridStyle.CellSpacing = 0.5F
'Setting text pen for grid
gridStyle.TextBrush = PdfBrushes.Blue
'Applying style to grid
pdfGrid.Style = gridStyle
'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)

Font

Gets or sets the font.

public PdfFont Font { get; set; }

Property Value

PdfFont

The font.

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;
//Adding grid style
PdfGridStyle gridStyle = new PdfGridStyle();
//Allow grid to overflow horizontally
gridStyle.AllowHorizontalOverflow = true;
//Set background brush.
gridStyle.BackgroundBrush = PdfBrushes.Pink;
//Adding cell spacing between cells
gridStyle.CellSpacing = 0.5F;
//Setting text pen for grid
gridStyle.TextBrush = PdfBrushes.Blue;
//Set text pen.
gridStyle.TextPen = PdfPens.Red;
//Set font.
gridStyle.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 16, PdfFontStyle.Bold);
//Applying style to grid
pdfGrid.Style = gridStyle;
//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
'Adding grid style
Dim gridStyle As New PdfGridStyle()
'Allow grid to overflow horizontally
gridStyle.AllowHorizontalOverflow = True
'Set background brush.
gridStyle.BackgroundBrush = PdfBrushes.Pink
'Adding cell spacing between cells
gridStyle.CellSpacing = 0.5F
'Setting text pen for grid
gridStyle.TextBrush = PdfBrushes.Blue
'Set text pen.
gridStyle.TextPen = PdfPens.Red
'Set font.
gridStyle.Font = New PdfStandardFont(PdfFontFamily.Helvetica, 16, PdfFontStyle.Bold)
'Applying style to grid
pdfGrid.Style = gridStyle
'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)

TextBrush

Gets or sets the text brush.

public PdfBrush TextBrush { get; set; }

Property Value

PdfBrush

The text brush of the PdfGrid.

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;
//Adding grid style
PdfGridStyle gridStyle = new PdfGridStyle();
//Allow grid to overflow horizontally
gridStyle.AllowHorizontalOverflow = true;
//Set background brush.
gridStyle.BackgroundBrush = PdfBrushes.Pink;
//Adding cell spacing between cells
gridStyle.CellSpacing = 0.5F;
//Setting text pen for grid
gridStyle.TextBrush = PdfBrushes.Blue;
//Applying style to grid
pdfGrid.Style = gridStyle;
//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
'Adding grid style
Dim gridStyle As New PdfGridStyle()
'Allow grid to overflow horizontally
gridStyle.AllowHorizontalOverflow = True
'Set background brush.
gridStyle.BackgroundBrush = PdfBrushes.Pink
'Adding cell spacing between cells
gridStyle.CellSpacing = 0.5F
'Setting text pen for grid
gridStyle.TextBrush = PdfBrushes.Blue
'Applying style to grid
pdfGrid.Style = gridStyle
'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)

TextPen

Gets or sets the text pen.

public PdfPen TextPen { get; set; }

Property Value

PdfPen

The text pen.

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;
//Adding grid style
PdfGridStyle gridStyle = new PdfGridStyle();
//Allow grid to overflow horizontally
gridStyle.AllowHorizontalOverflow = true;
//Set background brush.
gridStyle.BackgroundBrush = PdfBrushes.Pink;
//Adding cell spacing between cells
gridStyle.CellSpacing = 0.5F;
//Setting text pen for grid
gridStyle.TextBrush = PdfBrushes.Blue;
//Set text pen.
gridStyle.TextPen = PdfPens.Red;
//Applying style to grid
pdfGrid.Style = gridStyle;
//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
'Adding grid style
Dim gridStyle As New PdfGridStyle()
'Allow grid to overflow horizontally
gridStyle.AllowHorizontalOverflow = True
'Set background brush.
gridStyle.BackgroundBrush = PdfBrushes.Pink
'Adding cell spacing between cells
gridStyle.CellSpacing = 0.5F
'Setting text pen for grid
gridStyle.TextBrush = PdfBrushes.Blue
'Set text pen.
gridStyle.TextPen = PdfPens.Red
'Applying style to grid
pdfGrid.Style = gridStyle
'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

Clone()

Creates a new object that is a copy of the current instance.

public object Clone()

Returns

object

A new object that is a copy of this instance.

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;
//Adding grid style
PdfGridStyle gridStyle = new PdfGridStyle();
//Allow grid to overflow horizontally
gridStyle.AllowHorizontalOverflow = true;
//Set background brush.
gridStyle.BackgroundBrush = PdfBrushes.Pink;
//Adding cell spacing between cells
gridStyle.CellSpacing = 0.5F;
//Setting text pen for grid
gridStyle.TextBrush = PdfBrushes.Blue;
//Applying style to grid
pdfGrid.Style = gridStyle;
//Draw grid to the page of PDF document.
pdfGrid.Draw(page, new PointF(10, 10));
//Clone the PDF grid style instance.
PdfGridStyle style1 = gridStyle.Clone() as PdfGridStyle;
style1.Font = new PdfStandardFont(PdfFontFamily.Courier, 8);
pdfGrid.Style = style1;
pdfGrid.Draw(page, new PointF(10, 100));
//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
'Adding grid style
Dim gridStyle As New PdfGridStyle()
'Allow grid to overflow horizontally
gridStyle.AllowHorizontalOverflow = True
'Set background brush.
gridStyle.BackgroundBrush = PdfBrushes.Pink
'Adding cell spacing between cells
gridStyle.CellSpacing = 0.5F
'Setting text pen for grid
gridStyle.TextBrush = PdfBrushes.Blue
'Applying style to grid
pdfGrid.Style = gridStyle
'Draw grid to the page of PDF document.
pdfGrid.Draw(page, New PointF(10, 10))
'Clone the PDF grid style.
Dim style1 As PdfGridStyle = TryCast(gridStyle.Clone(), PdfGridStyle)
style1.Font = New PdfStandardFont(PdfFontFamily.Courier, 8)
pdfGrid.Style = style1
pdfGrid.Draw(page, New PointF(10, 100))
'Save the document.
doc.Save("Output.pdf")
'close the document
doc.Close(True)