关于imaginelist的一段代码,帮忙看下错误
private void btnConfirm_Click(object sender, EventArgs e){
object[] myImage = new object[4];
imageList1.ColorDepth = ColorDepth.Depth32Bit;
myImage[0] = Image.FromFile(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + @"D:\animepicture\kkx.bmp");
myImage[1] = Image.FromFile(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + @"D:\animepicture\saber.bmp");
myImage[2] = Image.FromFile(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + @"D:\animepicture\shana.bmp");
myImage[3] = Image.FromFile(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + @"D:\animepicture\zzh.bmp");
for (int j = 0; j < 4; j++)
{
imageList1.Images.Add("pbchcrd" + "j", (Image)(myImage[j]));
}
Random rch = new Random();
int i = rch.Next(4);
pbCharcter1.Image = imageList1.Images[i];
imageList1.Images.RemoveByKey("pbchcrd" + "i");
}
系统没提示报错,一点击按钮就自动关闭窗体了