当在单元格中输入数据时 进行验证,当验证有误时就 将您输入单元格的数据清空(或将输入的数据选中)!急急急急急急……
希望高手给我明确的代码!谢谢了!

解决方案 »

  1.   

         dataGridView1.Rows[2].Cells["列名"].Value = String.Empty; 
      

  2.   

    dataGridView1.Rows[0].Cells[0].Value = "1";第1行第1列.
      

  3.   

    添加一个dataGridView控件,命名为dgv//模拟判断结果的变量
    bool judgeResult=true;
    public Form1()
            {
                InitializeComponent();            dgv.Rows[0].Cells[0].Value = 1;
                dgv.Rows[0].Cells[1].Value = "Kensou";            //接下来清空第一行第一个单元格的内容,即1
                if(judgeResult) 
                   dgv.Rows[0].Cells[0].Value = null;
            }
      

  4.   

    没有试,不知道这样行不~~dataGridView有一个dataError()事件,
    dataGridView1.selectedCell.Value=""
      

  5.   


            private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
            {
                if ("验证有误")
                    this.dataGridView1[e.ColumnIndex, e.RowIndex].Value = null;
            }
      

  6.   

     private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
            {
                //GoodsNum 为定义的该单元格的名称;
               if (this.dataGridView1.CurrentCell.OwningColumn.Name == "GoodsNum")
                {
                    ((TextBox)e.Control).TextChanged += new EventHandler(textBox2_TextChanged);
                }
            }
     private void textBox2_TextChanged(object sender, EventArgs e)
            {
                //ValidateClass 为判断该输入的数据是否为数字!
                ValidateClass validateclass = new ValidateClass();
                if (this.dataGridView1.CurrentCell.OwningColumn.Name == "GoodsNum")
                {
                    if (validateclass.validateNum(aa))
                    {                }
                    else
                    {
                        MessageBox.Show("您输入的格式有误!");
                        
                    }
                }
            }
     我需要当弹出对话框出来时,同时将该输入的值 进行清空!你高手给我答案!急急急急急……
      

  7.   

    其实上面都是你要的答案了...你只要想办法找到你要删除的某一行某一列 然后把Value 设置为空就好吗?
    MessageBox.Show("您输入的格式有误!"); 
    dataGridView1.CurrentRow.Cells["GoodsNum"].Value = "";实在不行
    MessageBox.Show("您输入的格式有误!"); 
    ((TextBox)sender).Text = ""; //不知道行不行
      

  8.   

    ((TextBox)sender).Text = ""; //不知道行不行
    上边的都不能清空,反而 这一句能成功!谢谢了