Page 1 of 1

How to copy formsMap content into Clipboard (c#)

Posted: Wed Sep 18, 2024 1:12 pm
by Bernd Welter
I tried to capture the formsMap content into the WIndows Clipboard via C# programming. Here's how I succeeded:

Code: Select all

private void btnMap2Clipboard_Click(object sender, EventArgs e)
{
    Bitmap bitmap = new Bitmap(formsMap1.Width, formsMap1.Height);
    formsMap1.DrawToBitmap(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
    Clipboard.SetImage(bitmap);
}
:!: Be aware that this approach copies not only the map itself but also all control connected "subcontrols" such as
  • Zoom slider
  • Magnifier
  • Coordinates...