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运行,大功告成!

  • 相关阅读:
    enum 与 enum class
    git error: unable to rewind rpc post data
    ip地址转换
    大端字节序&小端字节序(网络字节序&主机字节序)
    c++虚析构函数
    引用
    单例模式
    c++ 类静态成员、非静态成员初始化
    算法导论进度帖startedby20131029
    Linux驱动程序接口
  • 原文地址:https://www.cnblogs.com/xiaoni/p/3288524.html
Copyright © 2011-2022 走看看