日期:2014-05-18 浏览次数:21081 次
pb1[j] = new PictureBox(); pb1[j].Image = img; pb1[j].Tag = str; pb1[j].Name = j.ToString();
------解决方案--------------------
int total = 0;
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog op = new OpenFileDialog();
if (op.ShowDialog() == DialogResult.OK)
{
PictureBox p = new PictureBox();
//new add
p.tga=op.FileName;
p.Click += new EventHandler(p_Click);
p.SizeMode=PictureBoxSizeMode.Zoom;
p.BackColor=Color.Black;
p.Image = new Bitmap(op.FileName);
p.Width=50;
p.Height = 50;
int x=(total%5) *60;
int y=(total/5) *60;
p.Location=new Point(x,y);
this.panel1.Controls.Add(p);
total++;
}
}
void p_Click(object sender, EventArgs e)
{
string filenames = (string)((PictureBox)sender).Tag;
}