Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
i want to open the print dialog box
 
thanq
Posted 24-Nov-11 19:58pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can use javascript function window.print(); either on click of the button or on page load.
 
You can add the following code in page_load function
ScriptManager.RegisterClientScriptBlock(this.Page, typeof(string), "print", "window.print();", true);
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Use it just like any other dialog:
System.Windows.Controls.PrintDialog dialogue = new System.Windows.Controls.PrintDialog();
 
DialogResult dr = dialogue.ShowDialog();
if( dr == DialogResult.OK)
{
    // Do something
}
 
dialogue.Dispose();
  Permalink  
Comments
RaviRanjankr at 25-Nov-11 2:12am
   
5+
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You can use the PrintDialog like this
 PrintDocument pd = new PrintDocument();
            pd.PrintPage += new PrintPageEventHandler(PrintPage);
            PrintDialog pdi = new PrintDialog();
            pdi.Document = pd;
            if (pdi.ShowDialog() == DialogResult.OK)
            {
                pd.DocumentName = documentName;
                pd.Print();
            }
            else
            {
               MessageBox.Show("Print Cancelled");
            }
 
Hope this helps
  Permalink  
Comments
RaviRanjankr at 25-Nov-11 2:13am
   
5+
Wayne Gaylard at 25-Nov-11 2:28am
   
Thanks!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 8

use this :
// Configure printer dialog box
System.Windows.Controls.PrintDialog dlg = new System.Windows.Controls.PrintDialog();
dlg.PageRangeSelection = PageRangeSelection.AllPages;
dlg.UserPageRangeEnabled = true;
 
// Show save file dialog box
Nullable<bool> result = dlg.ShowDialog();
 
// Process save file dialog box results 
if (result == true)
{
    // Print document
}</bool>
 

http://msdn.microsoft.com/en-us/library/aa969773.aspx[^]
 
http://forums.asp.net/t/1474476.aspx/1[^]
 
http://www.c-sharpcorner.com/uploadfile/mahesh/printdialog-in-C-Sharp/[^]
 
how to open print dialog box in my c# application[^]
 
Thanks,
Ambesha
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

you can try this:
 PrintDocument item= new PrintDocument();
            item.PrintPage += new PrintPageEventHandler(PrintPage);
            PrintDialog pdi = new PrintDialog();
            pdi.Document = item;
            if (pdi.ShowDialog() == DialogResult.OK)
            {
                item.DocumentName = documentName;
                item.Print();
            }
            else
            {
               MessageBox.Show("Print Cancelled");
            }
thanks hope it helps!
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 540
1 Sergey Alexandrovich Kryukov 407
2 Yogesh Kumar Tyagi 384
3 Prakriti Goyal 280
4 Maciej Los 205
0 OriginalGriff 6,632
1 Sergey Alexandrovich Kryukov 5,429
2 Maciej Los 3,474
3 Peter Leow 3,309
4 DamithSL 2,495


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 26 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100