private void BtnFilter_Click(object sender, EventArgs e) { FrmSearchResult frm = new FrmSearchResult(); for (int i = 0; i < dgStudent.Rows.Count; i++) { DataGridViewRow r = dgStudent.Rows[i]; if (r.Cells[4].Value.ToString().Equals(cbNationalFilter.Text)) { frm.AddStudentInfo(r.Cells[0].Value.ToString(), r.Cells[1].Value.ToString(), r.Cells[2].Value.ToString(), r.Cells[3].Value.ToString(), r.Cells[4].Value.ToString(), r.Cells[5].Value.ToString(), r.Cells[6].Value.ToString(), r.Cells[7].Value.ToString()); } } frm.ShowDialog(); }
void SearchbyName() { FrmSearchResult frm = new FrmSearchResult(); for (int i = 0; i < dgStudent.Rows.Count; i++) { DataGridViewRow r = dgStudent.Rows[i]; if (r.Cells[1].Value.ToString().IndexOf(txtName.Text) > -1) { frm.AddStudentInfo(r.Cells[0].Value.ToString(), r.Cells[1].Value.ToString(), r.Cells[2].Value.ToString(), r.Cells[3].Value.ToString(), r.Cells[4].Value.ToString(), r.Cells[5].Value.ToString(), r.Cells[6].Value.ToString(), r.Cells[7].Value.ToString()); } } frm.ShowDialog(); }