Click here to Skip to main content
15,030,320 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am using the following codes to save the TableLayoutPanel to file :
C#
Bitmap bitmap = new Bitmap(tableLayoutPanel1.Width, tableLayoutPanel1.Height );
tableLayoutPanel1.DrawToBitmap(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
bitmap.Save("C:\\Temp\\Test.bmp");

My problem is the above codes only save 'a screen dump' of ~20 rows data of tableLayoutPanel1. There are > 60 rows in tableLayoutPanel1. How can I save all rows ? User is using a vertical scroll bar to view all data in tableLayoutPanel1.

Many Thanks.
JasHFR
Posted
Updated 3-Aug-12 4:24am
v2

1 solution

This might work. I am not sure but worth a try.

Bitmap bitmap = new Bitmap(tableLayoutPanel1.Width, tableLayoutPanel1.RowCount * tablelayoutPanel1.GetRowHeights()[0]);
tableLayoutPanel1.DrawToBitmap(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
bitmap.Save("C:\\Temp\\Test.bmp");
   
Comments
JasHFR 3-Aug-12 21:25pm
   
Sorry to say that it does not work. The bitmap image length is increase now but with blank space, not the tableLayoutPanel content.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900