private void txt_ValueChanged(object sender, EventArgs e) { var x = (int) Math.Min(Math.Max(0, txtX.Value), mapBox.Image.Width); var y = (int) Math.Min(Math.Max(0, txtY.Value), mapBox.Image.Height); mapBox.MoveTo(x, y); mapBox.Invalidate(); }