C#에서 DataGridViewRow 를 복사하려는데 오류가 자꾸 발생한다.
분명 설명에는 DataGridView.Rows.Add(DataGridViewRow )가 있다..
그런데 왜 오류가 날까....
이유는 Row에 값을 넣는 방법이 문제 였다 ㅡㅡ;;
대충 해결 방법
DataGridView dgv = new DataGridView();
... (dgv에 특정 데이터를 집어 넣은 상태);
DataGridView dGrid = new DataGridView();
DataGridViewRow dgvRow = new DataGridViewRow();
dgvRow = CloneWithValues(dgv.Rows[i]);
dGrid.Rows.Add(dgvRow);
public DataGridViewRow CloneWithValues(DataGridViewRow row);
{
DataGridViewRow clonedRow = (DataGridViewRow)row.Clone();
for (Int32 index = 0; index < row.Cells.Count; index++)
{
clonedRow.Cells[index].Value = row.Cells[index].Value;
}
return clonedRow;
}
함수로 만들었지만.. 문제는 Cell에 값을 넣는게 문제 였다..
Row를 만들고 셀에 값을 잘 넣어주면 해결 되더라능 ㅡㅡ;
'프로그래밍 > C#' 카테고리의 다른 글
| BinaryWriter pointer 사용(seek) (0) | 2012.08.06 |
|---|---|
| [ASP.NET C#]이미지 메타태그 값 수정하기 / keyword, comment / EXIF (0) | 2011.12.08 |
| [C#] MessageBox의 기능 (1) | 2010.07.05 |
| [C#] DataGridView (0) | 2010.07.02 |
| ListView 의 사용(detail) (0) | 2010.06.28 |