Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C# - How to print a ListView

Posted on 2008-06-17
8
Medium Priority
?
9,396 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

604 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