I am trying to figure out if it is possible to set the AutoFitColumnWidth or control the width of a column for the PDF output of a WPF Grid?
I have the following code for setting up my export options.
public
void
ExportToPdf(RadGridView grid)
{
grid.ElementExportingToDocument -= Grid_ElementExportingToDocument;
grid.ElementExportingToDocument += Grid_ElementExportingToDocument;
var exportOptions =
new
GridViewDocumentExportOptions
{
AutoFitColumnsWidth =
false
,
ExcludedColumns = { grid.Columns[9], grid.Columns[10], grid.Columns[11], grid.Columns[12] },
ShowColumnHeaders = grid.ShowColumnHeaders
};
var dialog =
new
SaveFileDialog
{
DefaultExt =
"pdf"
,
FileName = SelectedCollege.CollegeCD +
" - Roster.pdf"
,
Filter =
"Pdf Files|*.pdf"
};
if
(dialog.ShowDialog() ==
true
)
{
using
(var stream = dialog.OpenFile())
{
grid.ExportToPdf(stream, exportOptions);
}
}
}
I do not want ALL columns to auto size, because I have columns with single digit values in them and they look terrible squished together. I REALLY would like to set the width manually so the output looks good.
My Grid columns are all Width="*" on the XAML side. And as you can see I am subscribing to the "ElementExportingToDocument" event and styling the grid to look the way it needs to look as far as foreground and background sizes.
Are we limited only to the CellSelectionStyle properties when it comes to customizing the export?