private void Form1_Load(object sender, EventArgs e)
{
int x=50,y=50;
for(int i =0;i<=20;i++)
{
if(x<=500)
{
PictureBox pb = new PictureBox();
pb.Location = new Point(x, y);
pb.Image = Image.FromFile("42032B59-017F-46B4-AC11-8FDF52B40A6D.jpg");
pb.Size = Image.FromFile("42032B59-017F-46B4-AC11-8FDF52B40A6D.jpg").Size;
this.Controls.Add(pb);
pb.Tag = 10;
x=x+50;
}
else
{
x=50;
y=y+50;
}
}
}
private void Form1_Click(object sender, EventArgs e)
{
if (sender is PictureBox)
{
Label lb = new Label();
lb.AutoSize = true;
lb.Text = "aldfjaslkjflasdjflkajksdklfjasdjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj";
lb.Location = MousePosition;
this.Controls.Add(lb);
}
}
这么先生成几个图像,然后在鼠标点击的时候建一个LABEL然后显示出信息,可是我这么写之后点击图片的时候完全没有反应,点击空白的地就可以进行调试