如果用TextBoxCell,可以试一下这样:
- private void Form1_Load(object sender, EventArgs e)
- {
- this.gcMultiRow1.EditingControlShowing += gcMultiRow1_EditingControlShowing;
- }
- void gcMultiRow1_EditingControlShowing(object sender, EditingControlShowingEventArgs e)
- {
- if (e.Control is TextBoxEditingControl)
- {
- (e.Control as TextBoxEditingControl).KeyPress += Form1_KeyPress;
- }
- }
- void Form1_KeyPress(object sender, KeyPressEventArgs e)
- {
- if ((Control.ModifierKeys & (Keys.Control | Keys.Alt)) == Keys.None)
- {
- if (e.KeyChar < '0' || e.KeyChar > '9')
- {
- e.Handled = true;
- }
- }
- }
复制代码 |