zoukankan      html  css  js  c++  java
  • 在WPF中加载Windows中的ReportViewer控件

    在项目中同事需要将Reporter中的控件嵌入到WPF中,所以找了一些相关资料

    与大家共同学习

     

    首先,需要向项目中的reference添加两个dll,一个是.NET库中的System.Windows.Forms

    另一个是 Microsoft.ReportViewer.WinForms控件

    然后WPF中的Window引入域名空间

    <Window x:Name="main" x:Class="WpfApplication_Demo.MainWindow"

    xmlns:wf ="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"

    xmlns:rv="clr-namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="Hosting Windows Forms Control In WPF" Height="300" Width="650">

    最后就是加载我们的ReportViewer控件了

    示例如下:

    <Grid>

    <DockPanel>

    <WindowsFormsHost>

    <rv:ReportViewer x:Name="_reportViewer" Width="300" ProcessingMode="Remote">

     

    </rv:ReportViewer>

    </WindowsFormsHost>

    </DockPanel>

    </Grid>

    接下来 就是写后台代码了

    public MainWindow()

    {

    InitializeComponent();

    //_reportViewer.Load += ReportViewer_Load;

    _reportViewer.ServerReport.ReportPath = "/MESReprots/TOP5";

    _reportViewer.ServerReport.ReportServerUrl = new Uri("http://192.168.6.20/reportserver");

    _reportViewer.RefreshReport();

     

    }

    F5运行,大功告成!

  • 相关阅读:
    Eclipse 介绍
    XML 解析之 dom4j 解析器
    XPath 快速入门
    XML 解析之 jaxp 解析器
    XML 之快速入门
    java操作Excel
    识别jar的编译JDK版本
    IntelliJ Idea 工具
    单点登录SSO
    java泛型-类型擦除
  • 原文地址:https://www.cnblogs.com/xiaoni/p/3288524.html
Copyright © 2011-2022 走看看