标题:求助:InvalidArgument=“0”的值对于“index”无效
取消只看楼主
lanke711
Rank: 9Rank: 9Rank: 9
来 自:流浪在天国之路
等 级:蜘蛛侠
威 望:7
帖 子:317
专家分:1437
注 册:2015-7-16
结帖率:100%
 问题点数:0 回复次数:0 
求助: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集合添加的两张图片


调试的情况如下:




请问各位前辈,为什么下标没有有效值?
2016-12-04 20:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-471977-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.132167 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved