C# Windows Formunu Yazdırma
2 Aralık 2016 / 09:09
Burak
Merhaba arkadaşlar;
Kullandığınız bir windows formunu yazdırmak isterseniz aşağıdaki kodlar işinizi rahatlıkla görücektir.Öncelikle kütüphanemizi yükleyelim
1 |
using System.Drawing.Printing; |
Kullanacagınız kodlar aşağıdaki gibidir;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
private void button1_Click(object sender, EventArgs e) { PrintDocument doc = new PrintDocument(); doc.PrintPage += this.Doc_PrintPage; PrintDialog dlgSettings = new PrintDialog(); dlgSettings.Document = doc; if (dlgSettings.ShowDialog() == DialogResult.OK) { doc.Print(); } } private void Doc_PrintPage(object sender, PrintPageEventArgs e) { float x = e.MarginBounds.Left; float y = e.MarginBounds.Top; Bitmap bmp = new Bitmap(this.groupBox1.Width, this.groupBox1.Height); this.groupBox1.DrawToBitmap(bmp, new Rectangle(0, 0, this.groupBox1.Width, this.groupBox1.Height)); e.Graphics.DrawImage((Image)bmp, x, y); } |
Etiketler: c# windows form print
Bu Yazılarıda Okuyabilirsiniz...
Bir yanıt yazın