求助:InvalidArgument=“0”的值对于“index”无效
一个pictureBox控件,一个imagelist控件,两个Button
代码如下:

private void Form1_Load(object sender, EventArgs e) { string Path = Application.StartupPath.Substring(0,Application.StartupPath.Substring(0,Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\")); Path += @"\11.jpg"; string Path2 = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\")); Path2 += @"\22.jpg"; Image Ming = Image.FromFile(Path,true); imageList1.Images.Add(Ming); Image Ming2 = Image.FromFile(Path2, true); imageList1.Images.Add(Ming2); imageList1.ImageSize = new Size(200,165); pictureBox1.Width = 200; pictureBox1.Height = 165; } private void button1_Click(object sender, EventArgs e) { pictureBox1.Image = imageList1.Images[0]; } private void button2_Click(object sender, EventArgs e) { pictureBox1.Image = imageList1.Images[1]; }
运行时,出现这个异常提示
这是ImageList控件的Image集合添加的两张图片
调试的情况如下:
请问各位前辈,为什么下标没有有效值?

普通人之所以普通,是因为他们普遍有一个通病,那就是认为自己永远普通。
千夫所指,我亦坚持。就算被所有人误解,我也照样守护这一切。
我们总是觉得,这些灵魂的表情,傲慢自大,目中无人,其实,真正目中无人的是我们。它们傲慢的不过是表情,而我们傲慢的却是行为!
记得,是为了忘记!
只要想着有那么一天,我就能忍受现在的每一天!
灾难并不可怕,可怕的是心中没有了希望。
你以为我在天堂,其实我正在路上。
当你觉得自己走不到终点的时候,请不要放弃。或许你的对手也是这种感觉。