เช็คค่าใน dataGridView ใช้ในกรณีตรวจหาค่าที่ต้องการ
ตัวอย่าง เช็คค่า Roll ตรวจสอบว่าเลขที่กรอกมาว่าถูกต้องไหม ว่ามีในฐานข้อมูลไหม
private void dgvCirculateDetail_CellValueChanged(object sender, DataGridViewCellEventArgs e) { this.checkRollNo(e); } private void checkRollNo(DataGridViewCellEventArgs e) { string Roll; switch (dgvCirculateDetail.Columns[e.ColumnIndex].Name) { case "RollNo": Roll = this.dgvCirculateDetail.CurrentRow.Cells["RollNo"].Value.ToString(); this._dsData.Tables[this._rollPairInCirculationManager.TableNameRollNo].Rows.Clear(); this._dsData.Merge(this._rollPairInCirculationManager.getRollNoListByNo(Roll)); if (_dsData.Tables[this._rollPairInCirculationManager.TableNameRollNo].Rows.Count == 0) { if (Roll != "") { MessageBox.Show("Not RollNo " + Roll + " !!", "Check RollNo"); } this.dgvCirculateDetail.CurrentRow.Cells["RollNo"].Value = ""; break; } else { DataTable dtRollNo = this._dsData.Tables[this._rollPairInCirculationManager.TableNameRollNo]; this.dgvCirculateDetail.CurrentRow.Cells["RollKey"].Value = dtRollNo.Rows[0]["RollKey"]; } break; } }