在 WPF 应用程序中使用 ReportViewer

要在 WPF 应用程序中使用 ReportViewer 控件,您需要将 ReportViewer 程序集添加到项目并以编程方式对其进行配置。 WPF 支持 Windows 窗体控件,但 ReportViewer 控件没有为 WPF 提供任何自动配置(而在 Windows 窗体应用程序中提供了此功能)。
在 WPF 应用程序中,ReportViewer 控件承载在 WindowsFormsHost 控件之中。 WindowsFormsHost 控件要求对调用代码的完全信任,这是 WPF 客户端应用程序在 Windows 中的信任级别。
1、在“添加引用”对话框中的“.NET”选项卡下,选择“Microsoft.ReportViewer.WinForms”程序集,然后单击“确定”。
2、XAML(这将在 XAML 页面上创建名为 _reportViewer 的 ReportViewer 实例。):

<Window x:Class="WpfReportApplication.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:rv="clr-namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms" 
        Title="MainWindow" Height="350" Width="525">
    <Grid>
      <WindowsFormsHost> 
        <rv:ReportViewer x:Name="_reportViewer"/> 
      </WindowsFormsHost>
    </Grid>
</Window>

参考学习:演练:在 WPF 应用程序中使用 ReportViewer

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值