20

In my WPF application, I am going to print the contents of my ListBox. I want to add a new control to the PrintDialog box to select the number of lines (items) to print.

Is it possible to customize the existing PrintDialog box and add a new control to bind to ListBox.Count?

Or is there a better way to do this?

enter image description here

Esoteric Screen Name
  • 6,082
  • 4
  • 29
  • 38
Roshil K
  • 2,583
  • 28
  • 38
  • 1
    Can you share with us the existing print dialog code with us ? – Smaug Mar 26 '13 at 14:34
  • Why would anyone want to specify the number of lines to print? As opposed to say pages. – Ryan Gates Mar 26 '13 at 18:20
  • @RameshMuthiah, by "existing PrintDialog", I'm pretty sure he means `System.Windows.Controls.PrintDialog` - so he wouldn't have any source code for that. I'm guessing he means "I want to add", instead of "I added". – Daniel Schilling Mar 26 '13 at 20:10
  • @Daniel.Thanks.You are right.I have edited the question. – Roshil K Mar 27 '13 at 04:15
  • @ Ryan Gates.Actually It is my project requirements.In mY project I have customised listbox and height of the each item in the list box is big in size.So it would be better to include "number of lines(items) to print" option. – Roshil K Mar 27 '13 at 04:21

2 Answers2

3

It's actually possible to extend common dialogs with .NET. I found this article on MSDN. However, I'm not sure whether this also applies to the print dialog or whether it can still be done, but I suggest you read that first.

Thorsten Dittmar
  • 55,956
  • 8
  • 91
  • 139
1

"C# provides a standard PrintDialog which has all the basic print dialog functionality. Since it is declared as a sealed class, there is no way to extend it through C# native syntax."

Please see the following link: http://www.codeproject.com/Articles/16797/Extending-C-PrintDialog-Part-I

You can always create your own "Printing dialog screen" from scratch , then you can add your drop down with the ammount of lines to print(dropdown) witch you then get from the listbox(concatenating or build string) and send to a specified printer.

Renier
  • 1,738
  • 3
  • 24
  • 51
  • 6
    actually System.Windows.Forms.PrintDialog is sealed System.Windows.Controls.PrintDialog isn't! – makc Mar 27 '13 at 10:05