0
DataGrid의 콤보 상자에 텍스트를 추가하는 데 문제가 있습니다. 여기에 문제가 있다고 말하는 데 문제가 있습니다. 누군가가 나에게 올바른 방법을 보여줄 수 있다면 고마워.DataGridView ComboBox 인덱스가 잘못되었습니다.
참고 : 다른 모든 정보는 정확합니다.
다음은 코드입니다.
XmlNode node = doc.SelectSingleNode("/MovieData");
foreach (XmlNode movie in node.SelectNodes("Movie"))
{
if (movie != null)
{
DataGridViewRow row = (DataGridViewRow)movieListDataViewBox.Rows[0].Clone();
row.Cells[0].Value = movie["Name"].InnerText;
row.Cells[1].Value = movie["Rating"].InnerText;
row.Cells[2].Value = movie["Disk"].InnerText;
row.Cells[3].Value = movie["LengthHr"].InnerText + " Hr. " + movie["LengthMin"].InnerText + " Min.";
// clear the combobox here ?
foreach(XmlNode type in movie["Type"])
{
row.Cells[4].Value = type.InnerText; // This is wrong here
}
row.Cells[5].Value = movie["SeriesType"].InnerText;
row.Cells[6].Value = movie["Location"].InnerText;
row.Cells[7].Value = movie["Owner"].InnerText;
row.Cells[8].Value = movie["Date"].InnerText;
row.Cells[9].Value = movie["Time"].InnerText;
movieListDataViewBox.Rows.Add(row);
}
}
편집 : 다음은 XML 파일의 모양입니다.
<Movie>
<Name>Death Race</Name>
<Type>Action</Type>
<Type>Adventure</Type>
<Rating>R</Rating>
<Disk>Blu-Ray</Disk>
<Owner>N/A</Owner>
<Location>Basement</Location>
<SeriesType>Movie Series</SeriesType>
<LengthHr>1</LengthHr>
<LengthMin>51</LengthMin>
<Time>9 : 44 : 23 PM</Time>
<Date>10/16/2013</Date>
</Movie>
<Movie>
<Name>Death Race 2</Name>
<Type>Action</Type>
<Type>Adventure</Type>
<Rating>R</Rating>
<Disk>Combo</Disk>
<Owner>N/A</Owner>
<Location>Basement</Location>
<SeriesType>Movie Series</SeriesType>
<LengthHr>1</LengthHr>
<LengthMin>41</LengthMin>
<Time>9 : 52 : 34 PM</Time>
<Date>10/16/2013</Date>
</Movie>
콤보 상자에 값을 추가하려고하십니까? Forth 칼럼은 콤보 칼럼입니까? 나는 코드에서 정말로 말할 수 없다. 코드에 결함이있는 것을 알지만이 정보 없이는 당신을 도울 수 없습니다. – WozzeC
예. 예. 미안하지만 네 번째는 콤보 박스 셀이라고 설명 했어야 했어. 어떻게 결함이 있습니까? – deathismyfriend
"각 유형에 대해"마다 셀 값을 덮어 쓰고 있습니다. 나는 아무도 그 일을하지 않으면 내일 수정을 게시 할 것입니다. – WozzeC