Click here to Skip to main content
15,877,618 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please how do I add image logo on left side top of DataGridView and resize the image into smaller size and add it to the code below. Thanks in advance.

What I have tried:

C#
private void printToolStripButton_Click(object sender, EventArgs e)
{
    DGVPrinter printer = new DGVPrinter();
    printer.Title = "DataGridView Report";
    printer.SubTitle = "An Easy to Use DataGridView Printing Object";
    printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
    printer.PageNumbers = true;
    printer.PageNumberInHeader = false;
    printer.PorportionalColumns = true;
    printer.HeaderCellAlignment = StringAlignment.Near;
    printer.Footer = "Your Company Name Here";
    printer.FooterSpacing = 15;
Posted
Updated 21-Feb-21 5:39am
v6
Comments
Richard MacCutchan 21-Feb-20 7:10am    
Check the documentation for the DGVPrinter class.
[no name] 21-Feb-20 14:16pm    
What's the question? Printing, the "logo", or "all of the above"?
Member 14522773 23-Feb-20 19:21pm    
Please this is the actual code am referring to, the image size is too big and I want to crop it, please can you help me with any code to solve this issue.thanks in advance.


DGVPrinter.ImbeddedImage img1 = new DGVPrinter.ImbeddedImage();
DGVPrinter printer = new DGVPrinter();
Bitmap bitmap1 = new Bitmap(@"C:\Users\fk\documents\visual studio 2013\Projects\Grace_Inventory_Login\Grace_Inventory_Login\Resources\key4.png");
// This code is to crop the image size
System.Drawing.Bitmap(bitmap, 60, 50 img1.Width, img1.Height);
img1.theImage = bitmap1; img1.ImageX = 0; img1.ImageY = 10;
img1.ImageAlignment= DGVPrinter.Alignment.NotSet;
img1.ImageLocation = DGVPrinter.Location.Header;
printer.ImbeddedImageList.Add(img1);

Seems you are using the code from this: Another DataGridView Printer[^]
I'd suggest to ask an author of above article.
 
Share this answer
 
Please this is the actual code am referring to, the image size is too big and I want to crop it, please can you help me with any code to solve this issue.thanks in advance.


DGVPrinter.ImbeddedImage img1 = new DGVPrinter.ImbeddedImage();
DGVPrinter printer = new DGVPrinter();
Bitmap bitmap1 = new Bitmap(@"C:\Users\fk\documents\visual studio 2013\Projects\Grace_Inventory_Login\Grace_Inventory_Login\Resources\key4.png");
// This code is to crop the image size
System.Drawing.Bitmap(bitmap, 60, 50 img1.Width, img1.Height);
img1.theImage = bitmap1; img1.ImageX = 0; img1.ImageY = 10;
img1.ImageAlignment= DGVPrinter.Alignment.NotSet;
img1.ImageLocation = DGVPrinter.Location.Header;
printer.ImbeddedImageList.Add(img1);
 
Share this answer
 
Can we print some text after printer.PrintDataGridView(dataGridView1);?
 
Share this answer
 
Comments
Richard Deeming 22-Feb-21 5:55am    
Your question is not a "solution" to someone else's question.

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