有个控件,通过PropertyGrid修改属性值。
在修改某个属性时(比如Text),如何能响应在这个属性上的回车键和鼠标双击时间?
麻烦给出Code,多谢!

解决方案 »

  1.   

    虽然在VS里面找不到KeyPress事件,但我手工加了这样的一句:
    this.dataGridView.KeyPress +=new KeyPressEventHandler(dataGridView_KeyPress);不过不触发dataGridView_KeyPress()还有就是鼠标双击,也是一样的。请高手指点。
      

  2.   

    validated事件 也不能处理回车事件
      

  3.   

    Control propertyGridView = propertyGrid.Controls[2];
    Type propertyGridViewType = propertyGridView.GetType();
    FieldInfo info = propertyGridViewType.GetField("edit",
    BindingFlags.Instance |
    BindingFlags.Static |
    BindingFlags.NonPublic |
    BindingFlags.DeclaredOnly |
    BindingFlags.Public);
    System.Windows.Forms.TextBox txtBox = info.GetValue(propertyGridView) as System.Windows.Forms.TextBox;txtBox.KeyDown += new KeyEventHandler(tb_KeyDown);