Mình gán ảnh vào mảng một chiều các button, run thử thì thấy thì bị lỗi runtime, mình ko hiểu tại sao các giá trị i khác không bị mà chỉ có i = 16 mới bị (đường dẫn file ảnh mình đã kiểm tra rùi), mong các bác giúp em
for (int i = 0; i < 24; i++)
{
string Location = "C:\\Users\\nguye\\Desktop\\CoCaNgua\\CoCaNgua\\FinishImage\\";
if (i < 6)
{
string ImageLocation = Location + "Red" + ((i % 6) + 1).ToString() + ".png";
FinishSquare[i] = new Button()
{
Image = new Bitmap(ImageLocation)
};
}
else if (i < 12)
{
string ImageLocation = Location + "BLue" + ((i % 6) + 1).ToString() + ".png";
FinishSquare[i] = new Button()
{
Image = new Bitmap(ImageLocation)
};
}
else if (i < 18)
{
string ImageLocation = Location + "Yellow" + ((i % 6) + 1).ToString() + ".png";
FinishSquare[i] = new Button()
{
Image = new Bitmap(ImageLocation)
};
}
else if (i < 24)
{
string ImageLocation = Location + "Green" + ((i % 6) + 1).ToString() + ".png";
FinishSquare[i] = new Button()
{
Image = new Bitmap(ImageLocation)
};
}
}
Error: An unhandled exception of type ‘System.ArgumentException’ occurred in System.Drawing.dll
Additional information: Parameter is not valid.
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?