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...
- private void Img_PrintlistDoc_MouseLeftButtonDown1(object sender, MouseButtonEventArgs e)
- {
- PrintDocument pd = new PrintDocument();
- pd.PrintPage += PrintPage;
- pd.Print();
- }
-
- private void PrintPage(object o, PrintPageEventArgs e)
- {
- DMSBusinessLayer service = new DMSBusinessLayer();
- List<DocumentsUser> objTble_Documents = new List<DocumentsUser>();
- int UserId = 0;
- string ImgName = string.Empty;
- foreach (DocumentsUser item in listView1.SelectedItems)
- {
- UserId = Convert.ToInt32(item.UserId);
- ImgName = item.Parent_File_Name;
- objTble_Documents = service.PrintUserDocuments(ImgName, UserId).AsEnumerable().Select(m => new DocumentsUser()
- {
- Child_File_Name = m.Field<string>("Child_File_Name"),
- FilePath = m.Field<string>("FilePath"),
- Parent_File_Name = m.Field<string>("Parent_File_Name")
- }).ToList();
- var items = objTble_Documents.SelectMany((x) => new[]
-
- new
- {Child_File_Name = x.Child_File_Name,FilePath = x.FilePath,Parent_File_Name = x.Parent_File_Name}});
- foreach (var i in items)
- {
- System.Drawing.Image img = System.Drawing.Image.FromFile(Convert.ToString(i.FilePath) + Convert.ToString(i.Parent_File_Name) + "_" + Convert.ToString(i.Child_File_Name));
- System.Drawing.Point loc = new System.Drawing.Point(100, 100);
- e.Graphics.DrawImage(img, loc);
- }
- }
- }
Kindly advice me... Please...