First select the path to save the image:
Copy the codeThe code is as follows:
= "Save";
= "*.png|*.png";
= true;
if (() == )
{
= true;
}
Secondly, save the control image (to wait for the savedialoge control to be completely closed, use timer to delay):
Copy the codeThe code is as follows:
= false;
Bitmap bit = new Bitmap(, );//Instantiate a bitmap as big as a form
Graphics g = (bit);
= ;// Set the quality to the highest
//(, , 0, 0, new Size(, ));//Save the entire form as a picture
((), , );//Save only a certain control
();//The default save format is PNG, and the quality of saving it into jpg format is not very good
if ((()))
{
("Screenshot was successful!");
return;
}