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

GridView Print Style - CheckBox Column

4 Answers 147 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ShareDocs
Top achievements
Rank 1
ShareDocs asked on 14 Nov 2012, 09:37 AM
Hello,

Checkbox column displays as "True" or "False" when preforming print preview.
Is there a way to display other values only on printing mode?
For example:
instead of true display + and instead of false display -

Thanks.

4 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 14 Nov 2012, 11:33 AM
Hello,

If you are using export to pdf for this, you should take a look at this documentation article.

And for your specific case, you can register for the HTMLCellFormatting event and do the following:
void exporter_HTMLCellFormatting(object sender, Telerik.WinControls.UI.Export.HTML.HTMLCellFormattingEventArgs e)
{
    if (e.GridCellInfo.Value is bool)
    {
        var boolValue = (bool)e.GridCellInfo.Value;
        e.HTMLCellElement.Value = boolValue ? "+" : "-";
    }
}

If you have any other questions, please let me know.

Best Regards,
Emanuel Varga
WinForms MVP
0
ShareDocs
Top achievements
Rank 1
answered on 14 Nov 2012, 11:46 AM
Hello,

I am using radGridView.PrintPreview function.
In order to use the exporter, I need to export the grid to html file.
Is there another solution for printing other values for boolean columns without saving a file?

Thanks.
0
Emanuel Varga
Top achievements
Rank 1
answered on 14 Nov 2012, 12:42 PM
Hello again,

For this you need to register to the PrintCellFormatting event and do the following:
private void grid_PrintCellFormatting(object sender, PrintCellFormattingEventArgs e)
{
    if (e.Column is GridViewCheckBoxColumn && e.Row.Cells[e.Column.Index].Value is bool)
    {
        e.PrintCell.Text = ((bool)e.Row.Cells[e.Column.Index].Value) ? "+" : "-";
    }
}

If you have any other questions, please let me know.

Best Regards,
Emanuel Varga
WinForms MVP
0
Ivan Petrov
Telerik team
answered on 19 Nov 2012, 07:37 AM
Hello guys,

Thank you both for writing.

Lior, Emanuel's solution is the right way to go in this situation. I am marking his post as answer in order to allow other users searching for this information to easily find it. You can read more on customizing the result of printing a grid in our online documentation - RadGridView Printing. 

Should you have further questions, do not hesitate to write back.
 
All the best,
Ivan Petrov
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
GridView
Asked by
ShareDocs
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
ShareDocs
Top achievements
Rank 1
Ivan Petrov
Telerik team
Share this question
or