I would like to know what is the easiest way to print ListBox's values. I have tried to use FlowDocumentReader but with no success.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If you are trying to print a visual element,you can use
PrintDialog printDlg = new PrintDialog();
printDlg.PrintVisual(ListBox1, "Listbox Printing.");
It can be used to print any visual object(any control, container, Window or user control)
If you are looking to print the items only then you can use the FlowDocument
FlowDocument fd = new FlowDocument();
foreach (object item in items)
{
fd.Blocks.Add(new Paragraph(new Run(item.ToString())));
}
fd.Print();
or
PrintDialog pd = new PrintDialog();
pd.PrintDocument(fd);