Created
December 7, 2019 16:00
-
-
Save relliv/f0610c22cd6bc937dd04704fe6626a62 to your computer and use it in GitHub Desktop.
Başka formdaki resmiyazdırma
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```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