有两个winform窗体,Form1中只有一个按钮,Form2为打印窗体,如下图
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Demo
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
////打印内容 为 局部的 this.groupBox1
Bitmap _NewBitmap = new Bitmap(190, 153);
groupBox1.DrawToBitmap(_NewBitmap, new Rectangle(0, 0, 190, 153));
e.Graphics.DrawImage(_NewBitmap, 0, 0, 190, 153);
}
private void Form2_Load(object sender, EventArgs e)
{
try
{
if (this.printDialog1.ShowDialog() == DialogResult.OK)
{
printDocument1.DefaultPageSettings.Landscape = false;
this.printDocument1.Print();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
this.Close();
}
}
}
}
现在的问题是程序走到加粗的代码那块时,好像就不再继续往下走了,然后整个项目都会卡死,请问谁能帮我解决一下?不清楚的可以加我Q: 4 7 2 1 7 4 8 7 7
已解决
156074228
图片已经挂掉了,麻烦重新上传