Tôi đang sử dụng mã bên dưới để in hình ảnh từ mã C# của tôi. Có thể một số cơ thể cho tôi biết làm thế nào để vượt qua filePath như một đối số khi tôi gán xử lý sự kiện của tôi?Cách chuyển thông số vào mã xử lý sự kiện của tôi để in hình ảnh
public static bool PrintImage(string filePath)
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(printPage);
pd.Print();
return true;
}
private static void printPage(object o, PrintPageEventArgs e)
{
//i want to receive the file path as a paramter here.
Image i = Image.FromFile("C:\\Zapotec.bmp");
Point p = new Point(100, 100);
e.Graphics.DrawImage(i, p);
}
cảm ơn. Nó đã làm việc. – Happy