how print a listview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • virtualKing
    New Member
    • Nov 2009
    • 3

    how print a listview

    please i need to print a listview, c#
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    What have you tried so far?
    Is your current code for printing producing an error or exception?
    MSDN "how-to" for printing a document

    Comment

    • Dheeraj Joshi
      Recognized Expert Top Contributor
      • Jul 2009
      • 1129

      #3
      You mean, how to display the items in list view?

      Regards
      Dheeraj Joshi

      Comment

      • virtualKing
        New Member
        • Nov 2009
        • 3

        #4
        no, i need print a listview in a printer. I have this code, but exist other opcion to print only text, not use a bitmap???
        Code:
                Font printFont;        
                Bitmap bitmap;
                public void PrintAString(Bitmap data)
                {
                    PrintDocument pd = new PrintDocument();
                    printFont = new Font("Arial", 12);            
                    pd.PrintPage += new PrintPageEventHandler(PrintPage);     
                    pd.DefaultPageSettings.Landscape = true;
                    pd.Print();
                }
        
                private void PrintPage(object sender, PrintPageEventArgs e)
                {            
                    bitmap = new Bitmap(this.listView2.Width, this.listView2.Height);
                    listView2.DrawToBitmap(bitmap, this.listView2.ClientRectangle);
                    e.Graphics.DrawImage(bitmap, new Point(70, 70));
                }
        
                private void imprimirToolStripMenuItem_Click(object sender, EventArgs e)
                {
                    PrintAString(bitmap);
                }
        Last edited by tlhintoq; Dec 1 '09, 04:48 PM. Reason: [CODE] ...your code here... [/CODE] tags added

        Comment

        • tlhintoq
          Recognized Expert Specialist
          • Mar 2008
          • 3532

          #5
          TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

          Comment

          Working...