0
我做了它的整數值,通過這個代碼,它的工作:DataGridView的細胞接受雙重價值只有
private void ItemsDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
DataGridViewTextBoxCell cell =ItemsDataGridView[2, e.RowIndex] as DataGridViewTextBoxCell;
if (cell != null)
{
if (e.ColumnIndex == 2)
{
char[] chars = e.FormattedValue.ToString().ToCharArray();
foreach (char c in chars)
{
if (char.IsDigit(c) == false)
{
MessageBox.Show("You have to enter digits only");
e.Cancel = true;
break;
}
}
}
我不想再拍細胞只接受雙重價值,以防止用戶輸入兩個點「 「。以避免錯誤
完美,謝謝 –