private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
e.CellStyle.BackColor = Color.Aqua;//设置编译时的颜
}
private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (dataGridView1.Rows[e.RowIndex].IsNewRow) { return; }
decimal newInteger;
if (e.ColumnIndex == 4 || e.ColumnIndex == 6)
{
if (e.FormattedValue != null && e.FormattedValue.ToString().Length != 0)
{
if (!decimal.TryParse(e.FormattedValue.ToString(), out newInteger) || newInteger < 0)
{
e.Cancel = true;
MessageBox.Show("请输入数字或小数","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
}
}