I am trying to create an application which prints listview
items and some pictures. In the first form, I fill listview and when I press the preview button it opens form 2 and prints my listview and other things.
private void Form1_Load(object sender, EventArgs e){
System.Drawing.Image img = System.Drawing.Image.FromFile("C:\\assda.jpg");
Point loc = new Point(100, 100);
d.Graphics.DrawImage(img, new Rectangle(10, 20, 195, 100), new Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel);
d.Graphics.DrawString("xxxxx", new Font("Times New Romans", 14, FontStyle.Bold), Brushes.Black, new PointF(350, 60));
}
I have to add PrintPageEventArgs d
but when I add like this:
private void Form1_Load(object sender, EventArgs e, PrintPageEventArgs d)
I get the following error:
No overload for 'Form1_Load' matches delegate 'System.EventHandler'
It shows the error in Form1.Designer.cs:
this.Load += new System.EventHandler(this.Form1_Load);
Add a new .cs and write something like that ;
override protected void print(PrintPageEventArgs e){
System.Drawing.Image img = System.Drawing.Image.FromFile("C:\\assda.jpg");
Point loc = new Point(100, 100);
d.Graphics.DrawImage(img, new Rectangle(10, 20, 195, 100), new Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel);
d.Graphics.DrawString("xxxxx", new Font("Times New Romans", 14, FontStyle.Bold), Brushes.Black, new PointF(350, 60));
}
Call this code where you want to use
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.