Abhilash J A

Abhilash J A

  • 533
  • 2.4k
  • 598.2k

How can I open printer window in WPF C#.Net

Dec 23 2016 1:50 PM
Hello everyone,
 
I have list images from database. And I want to print the images. But I can not do, showing printer window by using below c# code. How can open printer window something like that...
 
 
  
After binding my DataGrid with images that show like that...
 
  1. private void Img_PrintlistDoc_MouseLeftButtonDown1(object sender, MouseButtonEventArgs e)  
  2.        {  
  3. PrintDocument pd = new PrintDocument();  
  4.            pd.PrintPage += PrintPage;  
  5.            pd.Print();  
  6.        }  
  7.   
  8.  private void PrintPage(object o, PrintPageEventArgs e)  
  9.        {  
  10.            DMSBusinessLayer service = new DMSBusinessLayer();  
  11.            List<DocumentsUser> objTble_Documents = new List<DocumentsUser>();  
  12.            int UserId = 0;  
  13.            string ImgName = string.Empty;  
  14.            foreach (DocumentsUser item in listView1.SelectedItems)  
  15.            {  
  16.                UserId = Convert.ToInt32(item.UserId);  
  17.                ImgName = item.Parent_File_Name;  
  18.                objTble_Documents = service.PrintUserDocuments(ImgName, UserId).AsEnumerable().Select(m => new DocumentsUser()  
  19.                {  
  20.                    Child_File_Name = m.Field<string>("Child_File_Name"),  
  21.                    FilePath = m.Field<string>("FilePath"),  
  22.                    Parent_File_Name = m.Field<string>("Parent_File_Name")  
  23.                }).ToList();  
  24.                var items = objTble_Documents.SelectMany((x) => new[]  
  25.   
  26.    new  
  27.    {Child_File_Name = x.Child_File_Name,FilePath = x.FilePath,Parent_File_Name = x.Parent_File_Name}});  
  28.                foreach (var i in items)  
  29.                {  
  30.                    System.Drawing.Image img = System.Drawing.Image.FromFile(Convert.ToString(i.FilePath) + Convert.ToString(i.Parent_File_Name) + "_" + Convert.ToString(i.Child_File_Name));  
  31.                    System.Drawing.Point loc = new System.Drawing.Point(100, 100);  
  32.                    e.Graphics.DrawImage(img, loc);  
  33.                }  
  34.            }  
  35.        }  
 Kindly advice me... Please...
 

Answers (3)