473,325 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

C#.NET windows application+print a panel contents

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_s chedule.Location.X, this.panel_payment_schedule.Location.Y, 0, 0, s);
if (System.IO.File.Exists(@"c:\PrintPage.jpg"))
{
System.IO.File.Delete(@"C:\PrintPage.jpg");
}
memoryImage.Save(@"C:\PrintPage.jpg", ImageFormat.Jpeg);


Thanks for any help
Aug 21 '08 #1
1 8630
ovi123
1
Use this instead:

if (System.IO.File.Exists(@"c:\PrintPage.jpg"))
{
System.IO.File.Delete(@"C:\PrintPage.jpg");
memoryImage.Save(@"C:\PrintPage.jpg", ImageFormat.Jpeg);

}else
memoryImage.Save(@"C:\PrintPage.jpg", ImageFormat.Jpeg);

Accesing the harddrive is an asynchronous comunication and also is a low priority job (this means that deleting the file is not finished till the processor begin executing the instruction to overwrite it).
Apr 16 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Konrad Koller | last post by:
Under Windows print formatting (header, footer etc.) is OK. Under LINUX it does not work. SciTEGlobal.properties state around line 352: # Printing - only works on Windows Why? How is print...
3
by: PW | last post by:
I'm using the windows.print() function to print a customers receipts from an ASP. I've created a button to do it, like this ... <td align=left> <BUTTON TYPE=BUTTON...
0
by: JJ | last post by:
I'm using the CrystalReportViewer1.PrintReport() method in a vb.net exe but DO NOT want the Windows Print Box to appear (I require the report to print directly)
0
by: Phuff | last post by:
I need to be able to capture events thrown by the Amyuni print driver( a 3rd parter pdf conversion product), and it has specified numbers which I believe I understand to be thw wParam of the print...
2
by: newsgroper | last post by:
I set the AutoScroll property of a windows panel to true. How can I tell when the scrollbar becomes visible?
10
by: nutso fasst | last post by:
Hi. Any way to do this from asp page in IIS4? Application.Contents.Remove is IIS 5+. Setting variable to empty string does not remove variable. thx, nf
0
by: =?Utf-8?B?RXJpYw==?= | last post by:
Hello All, I have an Image where the corners of them are set to transparent (a=0, r=255, b=255,g=255) and I load this image as a Bitmap into the BackgroundImage property of a windows panel. When...
5
by: qhimq | last post by:
Hi, Has anyone ever heard of a program, when running, will catch all that is supposed to be printed by any program and show it on the screen, while suppressing the actual printout in the printer?...
2
by: Greg (codepug | last post by:
acCmdPrint allows me to print using the Windows Dialog. Since I want to be able to select the printer of my choice, this works well. I put his behind a button on a single form. The problem is,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.