Skip to content

Instantly share code, notes, and snippets.

@relliv
Created December 7, 2019 16:00
Show Gist options
  • Save relliv/f0610c22cd6bc937dd04704fe6626a62 to your computer and use it in GitHub Desktop.
Save relliv/f0610c22cd6bc937dd04704fe6626a62 to your computer and use it in GitHub Desktop.
Başka formdaki resmiyazdırma
```csharp
// açık olan formlar içinde dönelim
foreach (Form form in Application.OpenForms.OfType<Form>().ToList())
{
if (form.Name == "Form2")
{
// Form2'nin içindeki controller içinde dönelim
foreach (Control control in form.Controls)
{
if (control.Name == "pictureBox1")
{
// pictureBox'ı ele alalım
var pictureBox = control as PictureBox;
// burada artık nasıl yazdırıyorsan senindir
PrintDocument printDocument = new PrintDocument();
printDocument.PrintPage += (object sen, PrintPageEventArgs pea) =>
{
Point location = new Point(100, 100);
pea.Graphics.DrawImage(pictureBox.Image, location);
};
printDocument.Print();
break;
}
}
}
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment