我正在使用WinForms。在我的表单中,我有一个picturebox和一个打印按钮。是否有一种方法可以使我加载到picturebox中的图像始终位于打印预览窗口的中心?下面的图像显示了我的表单和打印预览屏幕中未居中的图像。
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Image = new Bitmap(@"C:\Users\Nav\Pictures\Test_Image.png");
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(pictureBox1.Image,50,50);
}
private void Btn_Print_Click(object sender, EventArgs e)
{
printPreviewDialog1.Document = printDocument1;
printPreviewDialog1.ShowDialog();
}
(50,50)
处绘制了它。 - Reza Aghaeie.Graphics.DrawImage(pictureBox1.Image, e.MarginBounds);
,它会给它一个边距,但同时也会拉伸图像。 - taji01