TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abhilash J A
533
2.4k
597.9k
How can print all images through listview select ?
Jan 4 2017 1:31 PM
Hello Everyone,
How can I select all images through select checkbox from listview then click on button. I have find code from google then used inside button click,
private
void
chkbtn_click(
object
sender, MouseButtonEventArgs e)
{
if
(objTble_Documents.Count() != 0)
{
try
{
PrintDocument pd =
new
PrintDocument();
pd.PrintPage +=
new
PrintPageEventHandler(PrintPage);
System.Windows.Forms.PrintDialog pdi =
new
System.Windows.Forms.PrintDialog();
pdi.Document = pd;
if
(pdi.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
pd.Print();
}
else
{
MessageBox.Show(
"Print Cancelled"
);
}
}
catch
(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
After applied this code,
private
void
PrintPage(
object
o, PrintPageEventArgs e)
{
List<ListViewItemsData> objListViewItemsData =
new
List<ListViewItemsData>();
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();
}
foreach
(var i
in
objTble_Documents)
{
objListViewItemsData.Add(
new
ListViewItemsData()
{
GridViewColumnName_ImageSource = (Convert.ToString(i.FilePath) + Convert.ToString(i.Parent_File_Name) +
"_"
+ Convert.ToString(i.Child_File_Name)),
});
}
foreach
(var ii
in
objListViewItemsData)
{
System.Drawing.Image img = System.Drawing.Image.FromFile(ii.GridViewColumnName_ImageSource.ToString());
System.Drawing.Rectangle m = e.MarginBounds;
if
((
double
)img.Width / (
double
)img.Height > (
double
)m.Width / (
double
)m.Height)
{
m.Height = (
int
)((
double
)img.Height / (
double
)img.Width * (
double
)m.Width);
}
else
{
m.Width = (
int
)((
double
)img.Width / (
double
)img.Height * (
double
)m.Height);
}
e.Graphics.DrawImage(img, m);
}
}
But run this much of code, printing only one image, that last image from the loop. How can I solve this issue? Please help me...
Reply
Answers (
1
)
Microservices in .Net
What is NetTiersProvider and How it is use ?