This is a migrated thread and some comments may be shown as answers.

Header Row Color in PDF

1 Answer 30 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bertha
Top achievements
Rank 1
Bertha asked on 25 Sep 2018, 08:09 PM

I am using WinForm and export the radgridview to pdf. I want the top header row has some grey color to distinguish it as header row.  How to do that?  Can I change the TableBorderThickness to be less than 1?

ExportToPDF exporter = new ExportToPDF(this.radGridView1);
exporter.TableBorderThickness = 1;

 

Thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Hristo
Telerik team
answered on 27 Sep 2018, 12:37 PM
Hello Bertha,

You can handle the CellFormatting event of the GridViewPdfExport object and change the back color of the cells located in the header row: 
      private void RadButton1_Click(object sender, EventArgs e)
    {
        var pdfExporter = new GridViewPdfExport(this.RadGridView1);
        pdfExporter.CellFormatting += pdfExporter_CellFormatting;
        var renderer = new PdfExportRenderer();
        string fileName = @"..\..\exported-grid.pdf";
 
        pdfExporter.RunExport(fileName, renderer);
    }
 
    private void pdfExporter_CellFormatting(object sender, PdfExportCellFormattingEventArgs e)
    {
        var headerRow = e.Row as GridViewTableHeaderRowInfo;
        if (headerRow != null)
            e.CellElement.BackColor = Color.Green;
    }

Another possible solution is to export the visual settings of the grid which will paint the header row in the exported documents as it is displayed in the control: 
GridViewPdfExport pdfExporter = new GridViewPdfExport(this.RadGridView1);
pdfExporter.ExportVisualSettings = true;

I hope this helps. Let me know if you need further assistance.

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Bertha
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or