Generation

generate functionMon, 20 Mar 2023

自定义一个picturebox然后给他注册一个事件

private void pictureBox1_Click(object sender, EventArgs e) { int x = (sender as PictureBox).Location.X; int y = (sender as PictureBox).Location.Y; int width = (sender as PictureBox).Width; int height= (sender as PictureBox).Height; if (x < 0 || x > this.Width - width) { x = 0; } if (y < 0 || y > this.Height - height) { y = 0; } (sender as PictureBox).Location = new Point(x, y); }

Questions about programming?Chat with your personal AI assistant