成都建站推广,做一个微信小程序需要多少钱,qq网页版在线登录官方,免费模板建站网站掌握WPF控件#xff1a;熟练常用属性#xff08;八#xff09;
PrintDialog
-一个对话框#xff0c;用于在打印文档时显示打印设置参数供用户选择并确认。通过该控件#xff0c;用户可以选择打印机、打印的范围、打印的份数、打印质量等。
常用属性描述CurrentPageEnab…掌握WPF控件熟练常用属性八
PrintDialog
-一个对话框用于在打印文档时显示打印设置参数供用户选择并确认。通过该控件用户可以选择打印机、打印的范围、打印的份数、打印质量等。
常用属性描述CurrentPageEnabled用于获取或设置一个值该指示打印当前页的选项是否可用。MaxPage用于获取或设置页范围内允许的最大页码。表示可在“ 打印 ”对话框的页范围中使用的最高页码。MinPage用于获取或设置页范围中允许的最小页码。表示可在“打印”对话框的页面范围中使用的最小页码。PageRange用于获取或设置当 PageRangeSelection 设置为 UserPages 时要打印的页面范围。PageRangeSelection用于获取或设置此 PrintDialog 实例的 PageRangeSelection。可选值:AllPages所有页、CurrentPage当前页、SelectedPages选定页、UserPages用户指定的范围页。PrintableAreaHeight用于获取页面的可打印区域的高度。PrintableAreaWidth用于获取页面的可打印区域的宽度。PrintQueue用于获取或设置一个 PrintQueue该字段表示所选的打印机。PrintTicket用于获取或设置当用户针对当前打印作业单击“打印”时 PrintDialog 使用的 PrintTicket。PrintTicket包含了打印设置的详细信息。SelectedPagesEnabled用于获取或设置指示是否启用打印所选页的选项的值。如果为true则允许用户选择要打印的页面范围如果为false则不允许用户选择要打印的页面范围。UserPageRangeEnabled用于获取或设置一个值该值指示“打印”对话框的用户是否可以使用一个选项指定要打印的页范围。为true表示可以使用选中指定打印范围。
下面来写个例子
GridStackPanel OrientationVertical VerticalAlignmentTop Margin20,20,20,0!--添加打开基本打印弹窗按钮--Button Content打开基本的PrintDialog对话框 BackgroundGreen ForegroundWhite Height50 Width250 FontSize16 Padding10,0 ClickButton_Click/Button!--添加有相关设置的打印弹窗按钮--Button Content打开有设置的PrintDialog对话框 BackgroundBlue Margin0,20,0,0 ForegroundWhite Height50 Width250 FontSize16 Padding10,0 ClickButton_Click_1/Button!--设置获取到打印区域的高度和宽度显示Label--Label x:NameMyLabel HorizontalAlignmentCenter FontSize16 ForegroundRed Margin0,20,0,0/Label/StackPanel
/Grid
using System.Printing;
using System.Windows;
using System.Windows.Controls;namespace WpfCommonControls
{/// summary/// PrintDialog.xaml 的交互逻辑/// /summarypublic partial class PrintDialogWindow : Window{public PrintDialogWindow(){InitializeComponent();}private void Button_Click(object sender, RoutedEventArgs e){//打开最基本的打印对话框PrintDialog printDialog new PrintDialog();//显示printDialog.ShowDialog();}private void Button_Click_1(object sender, RoutedEventArgs e){//有相关设置//打开最基本的打印对话框PrintDialog printDialog new PrintDialog();// 设置所有页printDialog.PageRangeSelection PageRangeSelection.AllPages;// 设置是否启用用户页面范围printDialog.UserPageRangeEnabled true;// 设置是否启用当前页面printDialog.CurrentPageEnabled true;// 设置是否启用选定页面printDialog.SelectedPagesEnabled true;//显示bool? print printDialog.ShowDialog();if (print true){//点击了打印按钮//获取打印区域宽度和高度double printableAreaWidth printDialog.PrintableAreaWidth;double printableAreaHeight printDialog.PrintableAreaHeight;//显示MyLabel.Content $当前打印区域宽度{printableAreaWidth}高度{printableAreaHeight};// 获取打印队列PrintQueue printQueue printDialog.PrintQueue;// 获取打印票证PrintTicket printTicket printDialog.PrintTicket;// 获取页面范围选择PageRangeSelection pageRangeSelection printDialog.PageRangeSelection;}else{// 点击了取消按钮MessageBox.Show(取消了打印);}}}
} 公众号“点滴分享技术猿”