C#.NET windows application+print a panel contents

  • 12 years ago

    my windows application form is divided into 3 split containers or split panels now what is my problem is i need to print the contents of the middle one container even if it is not seen full. but i get only the part of the panel that is visible. for example in excel sheet we can get the whole sheet content even it is in minimized condition. but at point copyFromScreen(), i get the picture of the parts of panel theta is visible and other dialogboxes sucha a print preview dialog box and other message box active at that time how can i get only the picture of the panel even if it is not fully visible to user.

    i need to print panel payment schedule.

    also i m getting problem while deleting the picture. it says file is in use cana not be deleted i have to delete it how can i delete it properly so that the picture of screen can be saved next time  with the same name.


    Graphics myGraphics = this.panel_payment_schedule.CreateGraphics();
               // MessageBox.Show("graphics created");
                Size s = this.panel_payment_schedule.Size;
                Bitmap memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
                Graphics memoryGraphics = Graphics.FromImage(memoryImage);
                memoryGraphics.CopyFromScreen(this.panel_payment_schedule.Location.X, this.panel_payment_schedule.Location.Y, 0, 0, s);
                if (System.IO.File.Exists(@"c:\PrintPage.jpg"))
                memoryImage.Save(@"C:\PrintPage.jpg", ImageFormat.Jpeg);

     Thanks for any help


Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Owning a computer without programming is like having a kitchen and using only the microwave oven” - Charles Petzold