有一个dataGridView1控件,写好了下面两个验让事件private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
}private void dataGridView1_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
{
}
我想在dataGridView1_Leave事件中直接调用上面两个验证事件,该如何调用?主要不知道如何传入DataGridViewCellValidatingEventArgs 与DataGridViewCellCancelEventArgs 类.private void myDataGridView1_Leave(object sender, EventArgs e)
{
    dataGridView1_CellValidating(sender,?);
    dataGridView1_RowValidating(sender,?);
}

解决方案 »

  1.   

    不好意思,是WinForm程序,没有说清楚,主要不知道怎么传第二个参数.上面两个事件用到了e作为方法调用.
      

  2.   

    事件这样简单调用就可以了:
            private void button1_Click(object sender, EventArgs e)
            {
                this.button2_Click(sender, e);
            }        private void button2_Click(object sender, EventArgs e)
            {
                MessageBox.Show("button2 has been clicked");
            }
      

  3.   

            private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
            {
                MessageBox.Show("111");
            }        private void dataGridView1_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
            {
                MessageBox.Show("222");
            }        private void dataGridView2_Leave(object sender, EventArgs e)
            {
                this.dataGridView1_CellValidating(sender,e as DataGridViewCellValidatingEventArgs);
                this.dataGridView1_RowValidating(sender, e as DataGridViewCellCancelEventArgs);
            }
      

  4.   

    楼上的方法不报错了,但传入的e参数是null,跟踪执行到上面的方法里需要e.RowIndex判断就有问题了.