所以我已經瀏覽了一些以前的解決方案,但迄今爲止還沒有看到任何解決我的問題。我試圖在點擊圖片框時更改玩家的頭像。我有一個圖像列表,像這樣:使用列表的IF語句<Bitmap>
List<Bitmap> avatars = new List<Bitmap>();
private void GameForm_Load(object sender, EventArgs e)
{
avatars.Add(Properties.Resources.Head1);
avatars.Add(Properties.Resources.Head2);
avatars.Add(Properties.Resources.Head3);
avatars.Add(Properties.Resources.Head4);
}
而這正是我試圖在改變它:
private void pictureBoxAvatar1_Click(object sender, EventArgs e)
{
if(pictureBoxAvatar1.Image == avatars.ElementAt(0))
{
pictureBoxAvatar1.Image = avatars.ElementAt(1);
}
//I have four total possibilities, but just have this one statement until I figure it out
}
我的問題是,我無法找到評估切換圖像的條件。
該方法奏效!感謝您的建議和批評,我一直在尋找更好的方法。 –