내 datagridView1에는 7 개의 열이 있고 첫 번째 열에 날짜가 있습니다.하나의 dataGridView에서 다른 것으로 전송하려고합니다.
for (int i = 0; i < f1.dataGrivView1.Rows.Count; i++)
{
if (f1.dataGrivView1.Rows[i].Cells[0].Value.ToString().Split('/')[1].StartsWith("01"))//if january..
{
dataGrivView1.Rows.Add();//datagridview in current form
dataGrivView1.Rows[i].Cells[0].Value = f1.dataGrivView1.Rows[i].Cells[0].Value.ToString();
dataGrivView1.Rows[i].Cells[1].Value = f1.dataGrivView1.Rows[i].Cells[1].Value.ToString();
}}
그리고 : 내가 dataGridView2 에 dataGridView1 가입일 January 데이터를 전송하기 위해 노력하고있어 나는 논리적으로 작동 것이라고 생각 루프를 사용하려고 노력하지만, 그것은 나에게 nullExceptions
을 줄 것 않았다 여기에 내 코드입니다 일부 인터넷 검색을 한 후에는 데이터를이 방법으로 복사 할 수 없으며 복제해야한다는 것을 알았습니다.
foreach (DataGridViewRow dgvr in f1.dataGridView1.Rows)
{
DataGridViewRow r = dgvr.Clone() as DataGridViewRow;
foreach (DataGridViewCell cell in dgvr.Cells)
{
if (cell.Value.ToString().Contains("/01/"));
r.Cells[cell.ColumnIndex].Value = cell.Value;
}
dataGridView1.Rows.Add(r);
}
하지만 .. 같은 것. 아이디어가 있으십니까?
날짜는 dd/mm/yyyy 형식이므로, (/ 01 /) 또는 startsWith (01) 작업 중 하나가 포함됩니다. – user3055826
첫 번째 그리드 데이터를 두 번째 그리드로 전송하려면 버튼을 클릭하십시오. 그런 다음 데이터 테이블 두 개를 유지하고 데이터 테이블 데이터를 사용하여 그리드가 데이터를 새로 고침 할 것을 제안합니다. –
다른 폼에서 'f1' . 나는 당신의'f1'이 null이라고 생각한다. – Fabio