我如何在WPF中打印窗口的特定部分 [英] how can i print particular part of window in wpf
本文介绍了我如何在WPF中打印窗口的特定部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我有像
这样的网格
hi all
i have grid like
<Grid x:Name="grid1" Visibility="Visible" Margin="14.717,241,0,99.685" HorizontalAlignment="Left" Width="401.283">
<Label Margin="90,27,197,0" Name="label12" FontSize="12" Height="26" VerticalAlignment="Top" FontWeight="Bold"></Label>
<Label Margin="197,27,88,0" Name="label13" FontSize="12" Height="25" VerticalAlignment="Top" FontWeight="Bold">DATE:</Label>
<Label HorizontalAlignment="Left" Margin="11,46.685,0,0" Name="label15" Width="80" FontSize="12" FontWeight="Bold" Height="29.315" VerticalAlignment="Top">VEHICLE No:</Label>
<Label Margin="11,0,0,20" Name="label16" FontSize="12" FontWeight="Bold" Height="27" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="124.545">PRICE :</Label>
<Label Margin="11,0,0,37" Name="label17" FontSize="12" FontWeight="Bold" HorizontalAlignment="Left" Width="124.545" Height="30.315" VerticalAlignment="Bottom">TOTAL TIME:</Label>
<Label Margin="197,48,76,0" Name="label18" FontSize="12" FontWeight="Bold" Height="29.315" VerticalAlignment="Top">ARRIVAL TIME:</Label>
<Label Margin="90,49,197,0" Name="label21" FontSize="12" FontWeight="Bold" Height="29.315" VerticalAlignment="Top"></Label>
<Label Margin="197,66,76,87.315" Name="label23" FontSize="12" FontWeight="Bold">DEPARTURE TIME</Label>
<Label HorizontalAlignment="Left" Margin="11,24.685,0,0" Name="label11" Width="80" FontSize="12" Height="25" VerticalAlignment="Top" FontWeight="Bold">Token No :</Label>
<Label FontSize="12" Height="25" HorizontalAlignment="Right" Margin="0,28,-40.76,0" Name="label28" VerticalAlignment="Top" Width="124" FontWeight="Bold"></Label>
<Label FontSize="12" HorizontalAlignment="Right" Margin="0,48,-9.828,0" Name="label29" Width="93.068" FontWeight="Bold" Height="28" VerticalAlignment="Top"></Label>
<Label FontSize="12" HorizontalAlignment="Right" Margin="0,66,-40.76,90" Name="label30" Width="124" FontWeight="Bold"></Label>
<Label FontSize="12" Margin="109,0,165,37" Name="label31" FontWeight="Bold" Height="30.315" VerticalAlignment="Bottom"></Label>
<Label FontSize="12" Margin="109,0,167,20" Name="label14" FontWeight="Bold" Height="27" VerticalAlignment="Bottom"></Label>
</Grid>
当我点击按钮
正在输出printo,但它正在打印整个窗口
除网格外,其余所有剩余部分留空白
我只需要在网格中打印特定内容
我写过类似
的代码
When I clicking button
am getting printo out but it is printing whole window
except grid all remaining part left white space
i need to print only particular content in grid
i have write code like
PrintDialog dialog = new PrintDialog();
//dialog.PrintableAreaHeight=pag
if (dialog.ShowDialog() == true)
{ dialog.PrintVisual(grid1, "My Canvas"); }
在这里,我只需要在网格内容上而不是在所有窗口上打印
here i need to get print on only grid content not all the window
please can any one please help me.
推荐答案
Printing a Control in WPF using C#
显示如何打印特定控件或整个表单.
Shows how you can print a particular control, or the whole form.
这篇关于我如何在WPF中打印窗口的特定部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文