Skip to content

Instantly share code, notes, and snippets.

@dchristensen
Created April 30, 2012 23:23
Show Gist options
  • Save dchristensen/2563600 to your computer and use it in GitHub Desktop.
Save dchristensen/2563600 to your computer and use it in GitHub Desktop.
Change a PictureBox dynamically
public partial class MapForm2 : Form
{
private Bitmap map_t;
private Bitmap map;
public MapForm2()
{
InitializeComponent();
var size = Properties.Resources.Penguins.Size;
map_t = new Bitmap("map.gif", true);
map = new Bitmap(map_t.Width, map_t.Height);
MapCanvas.Image = map;
}
private void MapCanvas_MouseUp(object sender, MouseEventArgs e)
{
var rect = new Rectangle(e.X - 3, e.Y - 3, 7, 7);
using (var g = Graphics.FromImage(map))
{
g.FillEllipse(Brushes.Red, rect);
}
MapCanvas.Invalidate();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment