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);

}

你可能感兴趣的:(DevExpress)