Kaydol:
Kayıt Yorumları
(
Atom
)
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; namespace WindowsFormsApplication2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } Panel panel; private void Form1_Load(object sender, EventArgs e) { for (int i = 0; i < 10; i++) { panel = new Panel(); panel.BackColor = System.Drawing.SystemColors.ActiveCaption; panel.Location = new System.Drawing.Point(43, 12 + (300 * i)); panel.Name = "panel1"; panel.Size = new System.Drawing.Size(200, 213); panel.TabIndex = 0; this.Controls.Add(panel); } printDocument1.Print(); } Control sonkontrol; int toplamuzunluk=0; int sayfa = 0; ListEklenenListe = new List (); private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { int uzunluk=0; foreach (Control nesne in this.Controls) { if(EklenenListe.Contains(nesne)) continue; if (uzunluk - sayfa * 1250 > 1200) { sayfa++; sonkontrol = nesne; break; } else sonkontrol = null; EklenenListe.Add(nesne); Bitmap bm = new Bitmap(nesne.Width, nesne.Height); nesne.DrawToBitmap(bm, new Rectangle(0, 0, nesne.Width, nesne.Height)); e.Graphics.DrawImage(bm, nesne.Location.X, nesne.Location.Y-toplamuzunluk); if(uzunluk < nesne.Height + nesne.Location.Y) uzunluk = nesne.Height + nesne.Location.Y; } toplamuzunluk += uzunluk; if(sonkontrol != null) e.HasMorePages = true; } } }
Hiç yorum yok :
Yorum Gönder