RDLC系列之五 初试XAML
本章只講解xaml部分,其余都和winform下一樣
1.xaml代碼
<Window x:Class="RDLC.WPF.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"Loaded="Window_Loaded" Closed="Window_Closed" Title="MainWindow" Height="350" Width="525"><WindowsFormsHost Name="windowsFormsHost"><rv:ReportViewer x:Name="reportView" /> </WindowsFormsHost> </Window>2.后臺代碼
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Microsoft.Reporting.WinForms;namespace RDLC.WPF {/// <summary>/// MainWindow.xaml 的交互邏輯/// </summary>public partial class MainWindow : Window{public MainWindow(){InitializeComponent();}private void Window_Loaded(object sender, RoutedEventArgs e){//代碼區域this.reportView.RefreshReport();}private void Window_Closed(object sender, EventArgs e){this.reportView.LocalReport.Dispose();this.reportView.LocalReport.ReleaseSandboxAppDomain();}} }?
3.DLL引用
MainWindow.xaml:
System.Windows.Forms
WindowsFormsIntegration? (.NET 4.0 才有,直接在程序集里面搜索)
MainWindow.xaml.cs:
Microsoft.ReportViewer.Common.dll、 Microsoft.ReportViewer.ProcessingObjectModel.dll、 Microsoft.ReportViewer.WebForms.dll和Microsoft.ReportViewer.WinForms.dll
注意:本次測試的Microsoft.ReportViewer的dll為版本號為11.0,試過使用9.0的,但是this.reportView.LocalReport.ReleaseSandboxAppDomain() 無法使用。
?
4.報表的工具欄
操作方法:在工具欄選擇或取消相應的屬性
例:不顯示刷新按鈕和導出按鈕
?<rv:ReportViewer x:Name="reportView" ShowRefreshButton="False" ShowExportButton="False"? />
?
轉載于:https://www.cnblogs.com/xcsn/p/4515179.html
總結
以上是生活随笔為你收集整理的RDLC系列之五 初试XAML的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: sql 按时间二段排序
- 下一篇: 区间素数筛法