Hi,
i have o problem whit the conversion of the content of a RadGridView in a RadDocument.
Inside of the RadGridView i have 5 columns with different width.
But the columns inside the RadDocument have all the same width.
My source code worked correctly whith the Telerik-Controls version 2014.3.1202.45.
The columns inside the RadDocument inherit the widths from the columns inside the RadGridView.
But after the update to the version 2018.1.220.45 it does not work correctly anymore.
The columns inside the RadDocument have all the same width.
Please, can you help me to find a solution?
Best Regards,
Vincent Dinculescu
Here my source code:
XAML of the RadGrisView:
. . . . . .
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn x:Name="vg_letztaend" Header="Datum"
Width="120"
DataMemberBinding="{Binding VgLetztaend}"
IsReadOnly="True"
TabStopMode="Skip"
IsFilterable="False"
IsSortable="True" />
<telerik:GridViewDataColumn x:Name="vg_betreff" Header="Betreff"
Width="270"
DataMemberBinding="{Binding VgBetreff}"
IsReadOnly="True"
TabStopMode="Stop"
IsFilterable="False"
IsSortable="True"
TextWrapping="Wrap" />
<telerik:GridViewDataColumn x:Name="vg_text" Header="Text"
Width="300"
DataMemberBinding="{Binding VgText}"
IsReadOnly="True"
TabStopMode="Stop"
TextWrapping="Wrap"
IsFilterable="False"
IsSortable="True" />
<telerik:GridViewDataColumn x:Name="bearbeiterName" Header="Bearbeiter"
Width="140"
DataMemberBinding="{Binding BearbeiterName}"
IsReadOnly="True"
TabStopMode="Skip"
IsFilterable="False"
IsSortable="True" />
<telerik:GridViewDataColumn x:Name="vg_bearbeiter" Header="Kennung"
Width="80"
DataMemberBinding="{Binding VgBearbeiter}"
IsReadOnly="True"
TabStopMode="Skip"
IsFilterable="False"
IsSortable="True" />
</telerik:RadGridView.Columns>
. . . . . .
Source code for the conversion from a RadGridView in a RadDocument:
public static void PrintPreview(this RadGridView grid)
{
Window owner = grid.GetVisualParent<Window>();
var rtb = CreateRadRichTextBox(grid);
PrintCommand = new DelegateCommand<object[]>(PrintData, CanExecutePrintCommand);
ExitCommand = new DelegateCommand<object>(Exit, CanExecuteExitCommand);
var window = CreatePreviewWindow(rtb, owner, settings);
window.ShowDialog();
}
private static RadRichTextBox CreateRadRichTextBox(RadGridView grid)
{
return new RadRichTextBox
{
IsReadOnly = true,
LayoutMode = DocumentLayoutMode.Paged,
IsSelectionEnabled = false,
IsSpellCheckingEnabled = false,
Document = CreateDocument(grid),
Padding = new Thickness(15, 10, 10, 10),
DocumentInheritsDefaultStyleSettings = true,
FontFamily = new FontFamily("Arial"),
FontSize = 12,
};
}
private static RadDocument CreateDocument(RadGridView grid)
{
RadDocument document;
using (var stream = new MemoryStream())
{
grid.Export(stream,
new GridViewExportOptions
{
Format = ExportFormat.Html,
ShowColumnFooters = grid.ShowColumnFooters,
ShowColumnHeaders = grid.ShowColumnHeaders,
ShowGroupFooters = grid.ShowGroupFooters
});
stream.Position = 0;
HtmlFormatProvider provider = new HtmlFormatProvider();
provider.ImportSettings = new HtmlImportSettings();
provider.ImportSettings.UseDefaultStylesheetForFontProperties = false;
document = provider.Import(stream);
document.SectionDefaultPageMargin = new Telerik.Windows.Documents.Layout.Padding(30);
document.SectionDefaultPageOrientation = PageOrientation.Landscape;
}
return document;
}
i have o problem whit the conversion of the content of a RadGridView in a RadDocument.
Inside of the RadGridView i have 5 columns with different width.
But the columns inside the RadDocument have all the same width.
My source code worked correctly whith the Telerik-Controls version 2014.3.1202.45.
The columns inside the RadDocument inherit the widths from the columns inside the RadGridView.
But after the update to the version 2018.1.220.45 it does not work correctly anymore.
The columns inside the RadDocument have all the same width.
Please, can you help me to find a solution?
Best Regards,
Vincent Dinculescu
Here my source code:
XAML of the RadGrisView:
. . . . . .
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn x:Name="vg_letztaend" Header="Datum"
Width="120"
DataMemberBinding="{Binding VgLetztaend}"
IsReadOnly="True"
TabStopMode="Skip"
IsFilterable="False"
IsSortable="True" />
<telerik:GridViewDataColumn x:Name="vg_betreff" Header="Betreff"
Width="270"
DataMemberBinding="{Binding VgBetreff}"
IsReadOnly="True"
TabStopMode="Stop"
IsFilterable="False"
IsSortable="True"
TextWrapping="Wrap" />
<telerik:GridViewDataColumn x:Name="vg_text" Header="Text"
Width="300"
DataMemberBinding="{Binding VgText}"
IsReadOnly="True"
TabStopMode="Stop"
TextWrapping="Wrap"
IsFilterable="False"
IsSortable="True" />
<telerik:GridViewDataColumn x:Name="bearbeiterName" Header="Bearbeiter"
Width="140"
DataMemberBinding="{Binding BearbeiterName}"
IsReadOnly="True"
TabStopMode="Skip"
IsFilterable="False"
IsSortable="True" />
<telerik:GridViewDataColumn x:Name="vg_bearbeiter" Header="Kennung"
Width="80"
DataMemberBinding="{Binding VgBearbeiter}"
IsReadOnly="True"
TabStopMode="Skip"
IsFilterable="False"
IsSortable="True" />
</telerik:RadGridView.Columns>
. . . . . .
Source code for the conversion from a RadGridView in a RadDocument:
public static void PrintPreview(this RadGridView grid)
{
Window owner = grid.GetVisualParent<Window>();
var rtb = CreateRadRichTextBox(grid);
PrintCommand = new DelegateCommand<object[]>(PrintData, CanExecutePrintCommand);
ExitCommand = new DelegateCommand<object>(Exit, CanExecuteExitCommand);
var window = CreatePreviewWindow(rtb, owner, settings);
window.ShowDialog();
}
private static RadRichTextBox CreateRadRichTextBox(RadGridView grid)
{
return new RadRichTextBox
{
IsReadOnly = true,
LayoutMode = DocumentLayoutMode.Paged,
IsSelectionEnabled = false,
IsSpellCheckingEnabled = false,
Document = CreateDocument(grid),
Padding = new Thickness(15, 10, 10, 10),
DocumentInheritsDefaultStyleSettings = true,
FontFamily = new FontFamily("Arial"),
FontSize = 12,
};
}
private static RadDocument CreateDocument(RadGridView grid)
{
RadDocument document;
using (var stream = new MemoryStream())
{
grid.Export(stream,
new GridViewExportOptions
{
Format = ExportFormat.Html,
ShowColumnFooters = grid.ShowColumnFooters,
ShowColumnHeaders = grid.ShowColumnHeaders,
ShowGroupFooters = grid.ShowGroupFooters
});
stream.Position = 0;
HtmlFormatProvider provider = new HtmlFormatProvider();
provider.ImportSettings = new HtmlImportSettings();
provider.ImportSettings.UseDefaultStylesheetForFontProperties = false;
document = provider.Import(stream);
document.SectionDefaultPageMargin = new Telerik.Windows.Documents.Layout.Padding(30);
document.SectionDefaultPageOrientation = PageOrientation.Landscape;
}
return document;
}