내 목록보기에서 항목을 선택하면 어떻게됩니까? 그게 한 번 작동합니다. 처음에 항목을 잘 선택하면 두 번째로는 [0] .SubItems [1] .Text; 0에.목록보기에서 항목 선택
이private void listViewFeatures_SelectedIndexChanged(object sender, EventArgs e)
{
ListView.SelectedListViewItemCollection features = listViewFeatures.SelectedItems;
string feature = features[0].SubItems[1].Text;
BL_AddReport addReport = new BL_AddReport(this.databaseConnectionString);
Dictionary<string, bool> pictures = addReport.GetpicturesFromFeature(feature);
foreach (KeyValuePair<string, bool> pic in pictures)
{
if (pic.Value) {
pictureBoxCar.Image = Image.FromFile(pic.Key);
}
else
{
pictureBoxEquip.Image = Image.FromFile(pic.Key);
}
}
}
사람이 문제가 무엇인지 알고 있나요 :
이 내가 가진 무엇인가?
왜 간단한'if' 문을 구현하지 않도록'features.Count> 0' 것을 확인하기 위해 그것으로 인덱싱하기 전에 내부에 아무것도가 변수 "기능"있는지 확인하십시오? 모든 문제가 사라졌습니다. –
Page_Load 이벤트 처리기에 코드를 표시하십시오. 로드중인 데이터를 다시로드하는 중일 수 있습니다. –
@Alex : 왜 이것이 ASP.NET 프로젝트라고 가정합니까? Windows Forms 일 수 있습니다 ... –