Reputation: 390
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.
Upvotes: 2
Views: 3748
Reputation: 18010
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);
Upvotes: 4