Ich habe eine WindowsForm mit zwei Textboxen ausgestattet. dazu ein Button, der das Drucken aktiviert.
Das drucken funktioniert soweit ganz gut.
Aber: Kann man es auch anders, effizienter machen ? Hat jemand ideen ?
Hier der Code:
(gibt es hier ein start und End-Tag für Codes ?)
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44:
| using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing.Printing; using System.IO;
namespace TestDruck_2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void btnDrucken_Click(object sender, EventArgs e) { printDocument1.DocumentName = textBox1.Text + textBox2.Text;
printDialog1.Document = printDocument1;
if (printDialog1.ShowDialog() == DialogResult.OK) { printDocument1.Print(); }
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.DrawString(textBox1.Text + Environment.NewLine + textBox2.Text, this.Font, Brushes.Black, e.MarginBounds); } } } |
Grüße
Jan
Moderiert von
Th69: C#-Tags hinzugefügt