DevExpress GridView限制列只允许输入数字

using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;

private void gridView1_KeyPress(object sender, KeyPressEventArgs e) {
    GridView view = sender as GridView;
    string s = "0123456789";
    if (view.FocusedColumn.FieldName == "CustomerID" && s.IndexOf(e.KeyChar) >= 0)
        e.Handled = true;
}
private void gridControl1_EditorKeyPress(object sender, KeyPressEventArgs e) {
    GridControl grid = sender as GridControl;
    gridView1_KeyPress(grid.FocusedView, e);
}
posted @ 2011-03-28 17:51  我在深圳搬砖  阅读(5319)  评论(3编辑  收藏  举报