你看一下这篇文章吧,DataGrid中的键盘事件比较复杂点
http://www.csdn.net/develop/Read_Article.asp?Id=16572

解决方案 »

  1.   

    你看一下Paint方法里面,有无不妥。
      

  2.   

    更改各个控件的TabIndex属性。
      

  3.   

    我的控里都是放在datagrid里面的,设什么TabIndex啊??晕~~
      

  4.   

    This behavior can be seen when you embedded a control like a textbox or combobox in your derived GridColumnStyle. If you press the tabkey slowly, you may see the cell get focus on the downkey and the cell lose focus on the upkey. One way to avoid this problem is to subclass the embedded control, and override its WndProc method, ignoring the KeyUp.
     
    [C#] 
     
    public class MyCombo : ComboBox 
     

     
    private const int WM_KEYUP = 0x101; 
      
    protected override void WndProc(ref System.Windows.Forms.Message m) 
     

     
    if(m.Msg == WM_KEYUP) 
     

     
    return; //ignore the keyup 
     

     
    base.WndProc(ref m);