日期:2014-05-18 浏览次数:20951 次
01.int num = 0;  
02.       private void dgTeam_DataError(object sender, DataGridViewDataErrorEventArgs e)  
03.       {  
04.           for (int i = 0; i < dgTeam.Rows.Count; i++)  
05.           {  
06.               try  
07.               {  
08.                   num = Convert.ToInt32(this.dgTeam.Rows[i].Cells[0].Value);  
09.                   num = Convert.ToInt32(this.dgTeam.Rows[i].Cells[1].Value);
                      //
                       //这边写   a *  b    =sum    相关代码
10.               }  
11.               catch  
12.               {  
13.                   MessageBox.Show("该项只能为数字,请重新填写", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);  
14.                   return;  
15.               }  
16.  
17.           }  
18.       }
------解决方案--------------------
楼主可以把当前点击的单元格变为as textbox,这样就可以限制只输入数字了.至于第三列e.columnindex就可以判断!