private void gridPurchaseOrderDetail_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { if (gridPurchaseOrderDetail.Columns[e.ColumnIndex].CellType.ToString().Contains("TextBox")) { if (Common.GetDecimal(e.FormattedValue) < 0) { MessageBox.Show("请检查输入数据的格式", "消息", MessageBoxButtons.OK); e.Cancel = true; } } }