Click here to Skip to main content
15,664,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
https://social.msdn.microsoft.com/Forums/getfile/854207[^]

Good day,
as you can see have a link above please click it for you to see.
I want to print that data from datagridview using printdocument without using any connection string connect to database.

I am using printdocument to print text, and here's my code.
e.Graphics.DrawString(dtgREPORT.Rows[l].Cells[1].FormattedValue.ToString(), dtgREPORT.Font = new Font("Arial", 10), Brushes.Black, new RectangleF(0, height, dtgREPORT.Columns[2].Width, dtgREPORT.Rows[0].Height));//stock numbr



What I have tried:

and I tried to create for the image, but it's error because of
FormattedValue.ToString()
and here's my code.
e.Graphics.DrawImage(dtgREPORT.Rows[l].Cells[2].FormattedValue.ToString(), dtgREPORT.Font = new Font("Arial", 10), Brushes.Black, new RectangleF(125, height, dtgREPORT.Columns[2].Width, dtgREPORT.Rows[0].Height));//image


I hope somebody can help me.
Posted
Updated 29-Dec-22 22:29pm
Comments
Graeme_Grant 31-Dec-22 21:32pm    
Please do not repost questions when you are not happy with the answer that you get. Update the original question with more information so others can better understand what you asked.

Reposted question here: Print all data in datagridview including image using printdocument in c#.[^]

1 solution

You don't pass a string to Graphics.DrawImage Method (System.Drawing) | Microsoft Learn[^] - there isn't an overload that takes one.
Instead, you need to get the Image that the cell contains and pass that instead.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900