1. Verify the events used Private void maid (Object sender, maid E) {// Used to verify a column of data Datagridview. Rows [E. rowindex]. errortext = string. empty; ... // Verify the data in each cell. } Private void datagridview1_dataerror (Object sender, datagridviewdataerroreventargs E) {// An error message is displayed when an exception is triggered during verification. If (! E. throwexception & E. Exception! = NULL) { MessageBox. Show (E. Exception. message, "system prompt", messageboxbuttons. OK, messageboxicon. Warning ); Datagridview1 [E. columnindex, E. rowindex]. Selected = true; Maid = maid [E. columnindex, E. rowindex]; E. Cancel = true; } } Private void maid (Object sender, maid E) {// Clear all errors when editing is stopped This. Maid [E. rowindex]. errortext = string. empty; } 2. Events used for data submission This. Validate (); // perform automatic verification This. Maid (); // end editing Verify each row and column of datagridview1 Submit data From: http://blog.csdn.net/yangwenling/archive/2008/03/10/2164059.aspx A specific verification event can be solved. If you believe it, you can read another article: Http://hi.baidu.com/fxb%5Fhyb/blog/item/146372237f2164469 |