menu

UWP

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class PdfGridColumn - UWP API Reference | Syncfusion

    Show / Hide Table of Contents

    Class PdfGridColumn

    Represents the schema of a column in a PdfGrid.

    Inheritance
    System.Object
    PdfGridColumn
    Namespace: Syncfusion.Pdf.Grid
    Assembly: Syncfusion.Pdf.UWP.dll
    Syntax
    public class PdfGridColumn : Object
    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);
    //Set the width for column1.
    column1.Width = 100;
    PdfGridColumn column2 = new PdfGridColumn(pdfGrid);
    //Set the width for column2.
    column2.Width = 200;
    PdfGridColumn column3 = new PdfGridColumn(pdfGrid);
    //Set the width for column3.
    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)
    'Set the width for column1.
    column1.Width = 100
    Dim column2 As New PdfGridColumn(pdfGrid)
    'Set the width for column2.
    column2.Width = 200
    Dim column3 As New PdfGridColumn(pdfGrid)
    'Set the width for column3.
    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)

    Constructors

    PdfGridColumn(PdfGrid)

    Initializes a new instance of the PdfGridColumn class with the parent grid.

    Declaration
    public PdfGridColumn(PdfGrid grid)
    Parameters
    Type Name Description
    PdfGrid grid

    The parent grid.

    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)

    Properties

    Format

    Gets or sets the information about the text formatting.

    Declaration
    public PdfStringFormat Format { get; set; }
    Property Value
    Type Description
    PdfStringFormat

    The format.

    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;
    //Creating new string formatting
    PdfStringFormat stringFormat = new PdfStringFormat();
    stringFormat.Alignment = PdfTextAlignment.Right;
    //Set string format
    pdfGrid.Columns[0].Format = stringFormat;
    //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
    'Creating new string formatting
    Dim stringFormat As New PdfStringFormat()
    stringFormat.Alignment = PdfTextAlignment.Right
    'Set string format
    pdfGrid.Columns(0).Format = stringFormat
    '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)

    Grid

    Gets the parent PdfGrid.[Read-Only]

    Declaration
    public PdfGrid Grid { get; }
    Property Value
    Type Description
    PdfGrid

    The grid.

    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;
    //Gets the parent grid
    PdfGrid parentGrid = pdfGrid.Columns[0].Grid;
    //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
    'Gets the parent grid
    Dim parentGrid As PdfGrid = pdfGrid.Columns(0).Grid
    '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)

    Width

    Gets or sets the width of the PdfGridColumn.

    Declaration
    public float Width { get; set; }
    Property Value
    Type Description
    System.Single

    The width.

    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;
    //Assign the column width.
    pdfGrid.Columns[0].Width = 50;
    pdfGrid.Columns[1].Width = 100;
    //Create Cell Style
    PdfGridCellStyle style = new PdfGridCellStyle();
    style.TextBrush = PdfBrushes.Cyan;
    //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
    'Assign the column width.
    pdfGrid.Columns[0].Width = 50;
    pdfGrid.Columns[1].Width = 100;
    'Create Cell Style
    Dim style As New PdfGridCellStyle()
    style.TextBrush = PdfBrushes.Cyan
    '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)

    Extension Methods

    DateTimeExtension.ToDateTime(Object)
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved