我正在使用WPF,它使用Infragistics dll进行报告生成和打印。
<igWPF:TabItemEx Name="tabEvent" Header="{x:Static p:resource.tab_reports_events}" >
<DockPanel VerticalAlignment="Stretch" >
<Button Content="{x:Static p:resource.tab_report_print}" HorizontalAlignment="Center" Click="btnAllEventPrint_Click" DockPanel.Dock="Bottom" Margin="0,10,0,0" Style="{StaticResource ButtonStyle}" Name="btnPrintAllEvent"/>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="30,0,0,10">
<TextBlock Text="{x:Static p:resource.tab_report_to}" Style="{StaticResource WPFTextBlockStyle}" Margin="20,0,0,0" FontWeight="DemiBold"/>
<ig:XamDateTimeInput Name="dtTo" Margin="10,0,0,0" Value="{x:Static System:DateTime.Now}"/>
<Button Content="{x:Static p:resource.tab_report_buttongo}" HorizontalAlignment="Center" Click="btnSearch_Click" Style="{StaticResource ButtonStyle}" Margin="50,0,0,0"/>
</StackPanel>
<dataPresenter:XamDataGrid x:Name="datagdEvent" DataSource="{Binding EventList}" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch" GroupByAreaLocation="None" FontFamily="Segoe UI" Visibility="Hidden" >
<dataPresenter:XamDataGrid.FieldLayoutSettings>
<dataPresenter:FieldLayoutSettings RecordSelectorLocation="None" AllowAddNew="False" AllowDelete="False" AutoGenerateFields="False" />
</dataPresenter:XamDataGrid.FieldLayoutSettings>
<dataPresenter:XamDataGrid.FieldLayouts>
<dataPresenter:FieldLayout >
<dataPresenter:FieldLayout.Fields>
<dataPresenter:Field Name="Machine" Label="{x:Static p:resource.tab_report_machine}" Width="0.6*">
<dataPresenter:Field.Settings>
<dataPresenter:FieldSettings AllowEdit="False" LabelTextAlignment="Center" EditorStyle="{StaticResource TextEditor}" />
</dataPresenter:Field.Settings>
</dataPresenter:Field>
<dataPresenter:Field Name="HouseNumber" Label="{x:Static p:resource.tab_houseNumber_Title}" Width="0.36*">
<dataPresenter:Field.Settings>
<dataPresenter:FieldSettings AllowEdit="False" LabelTextAlignment="Center" EditorStyle="{StaticResource TextEditor}" />
</dataPresenter:Field.Settings>
</dataPresenter:Field>
</dataPresenter:FieldLayout.Fields>
</dataPresenter:FieldLayout>
</dataPresenter:XamDataGrid.FieldLayouts>
</dataPresenter:XamDataGrid>
</DockPanel>
</igWPF:TabItemEx>
点击“打印”按钮,点击以下功能:btnAllEventPrint_Click
private void btnAllEventPrint_Click(object sender, RoutedEventArgs e)
{
Report reportObj = new Report();
reportObj.ReportSettings.HorizontalPaginationMode = HorizontalPaginationMode.Scale;
reportObj.PageHeaderTemplate = this.Resources["PagePresenterHeaderTemplate"] as DataTemplate;
string siteControllerName = RedeemVoucherView.getSiteControllerName();
reportObj.PageHeader = siteControllerName;
reportObj.ReportSettings.PageSize = new Size(3.15, 4);
reportObj.ReportSettings.Margin = new Thickness(0, 0, 0, 0);
reportObj.Sections.Add(section);
reportObj.Print(false, false);
//reportObj.Print(true, false);
}
// public void Print(bool showPrintDialog,bool showReportProgressControl);
带 showDialog = false 的打印功能给我错误,不会打印报告。使用2-3种类型的打印机
错误:参数异常被捕获.96.85&#39;不是属性&#39; Width&#39;的有效值。 &#39; -80.9759842519685&#39;不是属性的有效值&#39;宽度&#39;。
我可以使用任何打印机将 showdialog 值设置为true,成功打印文档。
我希望使用默认打印机打印报告,而不选择打印机名称/没有对话框选择菜单。
我怎么能实现这个目标?我错过了一些事情: