?
Solved

C# - How to print a ListView

Posted on 2008-06-17
8
Medium Priority
?
9,155 Views
Last Modified: 2013-12-16
Hello,

I am trying to print the contents of a ListView in C#, using Visual C# Express. I have no idea where to start, but I can't seem to find any good articles that explain it well. How would I go about printing the contents of the ListView box, as it appears on the screen?

Also - is it possible to send the data to a OpenDocument Template, and have that printed so it is themed how I want? If that is possible, and relatively quick and easy, I would like to go that method, but I am not sure at the moment. If not, I am quite happy with just being able to print the contents of the ListView box.

Thanks.
0
Comment
Question by:dh-s
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 21810602
PrintDialog prtDlg = new PrintDialog();
                    if (prtDlg.ShowDialog() == true)
                    {
                        prtDlg.PrintVisual(listview1, "ListView");
                    }
0
 

Author Comment

by:dh-s
ID: 21810792
HI gauthampj. I get the following errors when I try this. I tried it on a new project with a listBox (becuase they are easier to setup for a temp test). Using Windows XP SP2

Operator '==' cannot be applied to operands of type 'System.Windows.Forms.DialogResult' and 'bool'

'System.Windows.Forms.PrintDialog' does not contain a definition for 'PrintVisual' and no extension method 'PrintVisual' accepting a first argument of type 'System.Windows.Forms.PrintDialog' could be found (are you missing a using directive or an assembly reference?)

The exact code that I am using is...

            PrintDialog prtDlg = new PrintDialog();
            if (prtDlg.ShowDialog() == true)
            {
                prtDlg.PrintVisual(listBox1, "ListView");
            }

under the click event of a button that would initiate the print process, with a listBox that contains some items.
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 21810854
sorry ... change to
(prtDlg.ShowDialog() == DialogResult.Ok)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dh-s
ID: 21810981
Thanks. That fixes one of the errors, but I still get an error with prtDlg.PrintVisual...

System.Windows.Forms.PrintDialog' does not contain a definition for 'PrintVisual' and no extension method 'PrintVisual' accepting a first argument of type 'System.Windows.Forms.PrintDialog' could be found (are you missing a using directive or an assembly reference?)

Any suggestions here? Thanks!
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 21821292
which version are u suing 3.5 ?
0
 
LVL 3

Accepted Solution

by:
Pigtor earned 1500 total points
ID: 21823479
Check the following link
http://www.codeproject.com/KB/list/PrintableListView.aspx

I think this is what you are looking for.
0
 

Author Comment

by:dh-s
ID: 21837147
I am using version 3.5 of the .NET Framework, yes. Do I need to import anything to get it working?
0
 

Author Comment

by:dh-s
ID: 21837527
Pigtor: After a bit of fiddling, I managed to get a ListView to print using that particular link! Thanks heaps.
0

Featured Post

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question