Completed
Last Updated: 26 May 2016 07:30 by ADMIN
ADMIN
Hristo
Created on: 25 May 2016 10:11
Category: GridView
Type: Bug Report
0
FIX. RadGridView - when printing the cell padding set to the GridPrintStyle object is not respected for cells with HTML formatted text
How to reproduce: 

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        this.radGridView1.DataSource = this.GetData();
        this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
        this.radGridView1.Columns[0].DisableHTMLRendering = false;

        this.radGridView1.PrintCellFormatting += radGridView1_PrintCellFormatting;
    }

    private void radGridView1_PrintCellFormatting(object sender, Telerik.WinControls.UI.PrintCellFormattingEventArgs e)
    {
        e.PrintCell.EnableHtmlTextRendering = true;
    }

    private DataTable GetData()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Date", typeof(DateTime));
            dt.Columns.Add("Bool", typeof(bool));
            dt.Columns.Add("Description", typeof(string));
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    dt.Rows.Add(@"<html><b>Name " + j, DateTime.Now.AddDays(i), i % 2 == 0 ? true : false, "Description " + i);
                }
            }

            return dt;
        }

    private void radButton1_Click(object sender, EventArgs e)
    {
        GridPrintStyle style = new GridPrintStyle();
        style.FitWidthMode = PrintFitWidthMode.FitPageWidth;
        style.PrintGrouping = true;
        style.PrintSummaries = false;

        style.PrintHeaderOnEachPage = true;
        style.PrintHiddenColumns = false;
        style.CellPadding = new Padding(100, 0, 0, 0);

        this.radGridView1.PrintStyle = style;
        this.radGridView1.PrintPreview();
    }
}


Workaround: refer to the attached project
0 comments