C# 自定义DataGridViewTextBoxCell只能输入数字

public class myDataGridViewTextBoxColumn : DataGridViewTextBoxColumn
{
public myDataGridViewTextBoxColumn()
{
myDataGridViewTextBoxCell obj = new myDataGridViewTextBoxCell();
this.CellTemplate = obj;
}

}

public class myDataGridViewTextBoxCell : DataGridViewTextBoxCell
{
    protected override void OnKeyPress(KeyPressEventArgs e, int rowIndex)
    {            
        //只能输入数字
        if (!(char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
        {
            e.Handled = true; //输入是数字
        }
        else
            return;

        base.OnKeyPress(e, rowIndex);
    }     

}

    测试无效,甚至根本不执行OnKeyPress。不知道哪里有问题?

定义DataGridViewTextBoxCell只能输入数字
public class myDataGridViewTextBoxColumn : DataGridViewTextBoxColumn
{
public myDataGridViewTextBoxColumn()
{
myDataGridViewTextBoxCell obj = new myDataGridViewTextBoxCell();
this.CellTemplate = obj;
}

}
public class myDataGridViewTextBoxCell : DataGridViewTextBoxCell
{
protected override void OnKeyPress(KeyPressEventArgs e, int rowIndex)
{

//只能输入数字
if (!(char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
{
e.Handled = true; //输入是数字
}
else
return;

    base.OnKeyPress(e, rowIndex);
}     

}

测试无效,甚至根本不执行OnKeyPress。不知道哪里有问题?