PropertyGrid Guru needed for Custom Editor Problem.

If my custom drop down editor(which is basically a multiline text box) is removed from view because the user pressed escape, then I need to know so the propertygrid can ignore any changes made.  My 'fantasy vb code for the EditValue function would be.

MyCtrl.edSvc = edSvc: MyCtrl.Value = value
edSvc.DropDownControl(MyCtrl)

if dropdrown was removed with escape key then
     value is unchanged
else
     value = MyCtrl.Value
end if
return value


This is causing me a real headache.  Any advice would be appreciated - even if its to say its not possible.  Everything else works fine, its just this escape problem.

Thanks again


Answer this question

PropertyGrid Guru needed for Custom Editor Problem.

  • Ali Raza Shaikh

    Have you tried hooking the KeyPress event on the control your UITypeEditor instantiates   This should give you a chance to set a local field whether or not the esc key was pressed.

     - mike

  • S.Sriram

    Thanks for the reply.   This is the root of the problem.  User controls shown by the PropertyGrid on dropdown DON'T recieve KeyPress/Down/Up events for Escape or Enter Keys.

    Any ideas on how to actually get these key presses would be great.
    Could I get these from some 'Windows System Messages', you mentioned hooks

    P.S I'm using VB.NET, a sample project could be provided for anyone interested.

    Use of the PropertyGrid relies on this being solved.   Thanks again to anyone that replies.

  • Magoo

    Thats the problem.  How would I know to return the original value.  I need some indication that my control was 'finished' with by using the Escape key, so I can return the original value so no changes are made in the property grid.

    Thanks.


  • Pedro_Ignacio

    You're actually close.  If you return the original value from UITypeEditor.EditValue, the property grid won't do anything.


  • ChrisLyon

    Not sure if you have solved this as this question has been out here awhile, but could you override ProcessDialogKey and check there   I haven't done anything with CustomEditors, so it's a shot in the dark, but...



  • Ariel Valentin

    How will this help me know if the control was removed using the Escape or Enter Key

    Steve.

  • Miles Calunod

    Thanks JacobMVP - Your a star.  I'd given up on this but your ProcessDialogKey does the job for trapping the enter/escape keys.  Nice one.

    Thanks to all that helped.

    Steve-T

  • James_Steven

    Awesome...Glad it worked out!!

  • nycole

    Did you try hooking on to the VisibleChanged event
  • PropertyGrid Guru needed for Custom Editor Problem.