C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Save the Form & other controls as Bitmap


Posted Date: 09 Mar 2007    Resource Type: Code Snippets    Category: Images

Posted By: Manikandan Balakrishnan       Member Level: Gold
Rating:     Points: 10



Here’s a simple code, which enables save the form and other control as bitmap. This is very use full for the project documentation as well as for the reports. “DrawToBitmap” method provided for all the windows controls, which is used to perform this operation. Also we are not creating any “graphics”


public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{

SaveAsBitmap(this,"C:\\f1.bmp");

//The same way you can pass the controls like button,dataGrid etc
//SaveAsBitmap(mydataGrid,"C:\\report.bmp")
}

public void SaveAsBitmap(Control control, string fileName)
{
//getthe instance of the graphics from the control
Graphics g = control.CreateGraphics();

//new bitmap object to save the image
Bitmap bmp = new Bitmap(control.Width, control.Height);

//Drawing control to the bitmap
control.DrawToBitmap(bmp, new Rectangle(0, 0, control.Width, control.Height));

bmp.Save(fileName);
bmp.Dispose();

}

}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Create Thumbnail of an image
Previous Resource: Creating a ThumbNail Image on Fly
Return to Discussion Resource Index
Post New Resource
Category: Images


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

it support

Contact Us    Privacy Policy    Terms Of Use