绑定的列类型是数字的话,就不能输入其他的类型的

解决方案 »

  1.   

    我的列是动态构造的,不是绑定的,:-)我知道在那些事件处理,我想知道有什么好的方法控制
    只允许输入数字如 1  1.2 1.5 等
      

  2.   

    你只需添加事件处理就是了,参考如下:private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
    {
    decimal tmp = 0.0m;
    if (e.ColumnIndex ==3 && e.FormattedValue != null)
    {
    if (!decimal.TryParse(e.FormattedValue.ToString(), out tmp))
    {
    e.Cancel = true;
    }
    }
    }