私は C# にはかなり慣れていませんが、ようやく最初のプログラムを起動して実行し、それを印刷する必要があります。Excel に似た、さまざまなタブ コントロールに情報と計算を表示するウィンドウ フォームです。現在表示されているページは copyfromscreen メソッドで正常に印刷されますが、追加のページを正しく印刷することができません。一度に印刷できるようにしたいタブが約 20 あります。コントロールの内容をテキストファイルに印刷する方法を見つけましたが、フォームがどのように見えるかを印刷できるようにしたいと思っています。ありがとう。
Bitmap memoryImage;
Bitmap memoryImage2;
private void CaptureScreen()
{
Graphics myGraphics = this.CreateGraphics();
Size s = tabControlMain.Size;
s.Width = s.Width + 20;
memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
memoryGraphics.CopyFromScreen(this.Location.X+15, this.Location.Y+80, 0, 0, s);
tabControlMain.SelectedIndex = 1;
memoryImage2 = new Bitmap(s.Width, s.Height, myGraphics);
Graphics memoryGraphics2 = Graphics.FromImage(memoryImage2);
memoryGraphics2.CopyFromScreen(this.Location.X + 15, this.Location.Y + 80, 0, 0, s);
}
private void printDocumentReal_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(memoryImage, 0, 0);
e.Graphics.DrawImage(memoryImage2, 0, 550);
}
private void printToolStripButton_Click(object sender, EventArgs e)
{
CaptureScreen();
printDocumentReal.Print();
}