저는 C#으로 작성된 Windows Forms 응용 프로그램에서 작업하고 있습니다.DataGridView 내용을 사용자 지정 개체의 List <>로 변환하는 방법?
컨트롤에서 List<>
을 만드는 방법에 대한 제안을 찾았지만 셀 값을 추출하는 방법에 대한 도움이 필요합니다.
여기에 제공된 코드가 있습니다. dataGridView1
의 두 열이 Name
및 Address
인 경우,
List<ProjList>
개체를 만드는 방법은 무엇입니까?
foreach (DataGridViewRow dr in dataGridView1.Rows)
{
ProjList = new List<ProjectMasterRec>();
foreach (DataGridViewCell dc in dr.Cells)
{
// build out MyItem
// based on DataGridViewCell.OwningColumn and DataGridViewCell.Value
// how do we code this?
}
ProjList.Add(item);
}
모든 행 데이터를 가져 와서 문자열 형식으로 하나의 레코드로 나열 하시겠습니까? – Abdul