Menu

Ho do I disable default CellEditFinishing on Enter Key?

2016-05-16
2016-05-17
  • David Harrison

    David Harrison - 2016-05-16

    Hi, I have a column that uses a multiline TextBox as the text editor. I want the user to be able to add mulitple lines of text to be stored in the model object, possibly with blank lines etc. However, the default action of finishing cell editing on the Enter key prevents that. How can I disable that default action and instead enable some other action of my choice, e.g. pressing a F8 key or the Insert key or some such? I would, of course, have to re-instate the default action before I totally finshed up editing that cell for the other columns which have regular single line text editing.

    Thanks.

     
  • Phillip Piper

    Phillip Piper - 2016-05-16

    The behaviour of keys during editing is controlled by the CellEditKeyEngine.

    To have the engine simply pass through the Enter key, do this:

    this.CellEditKeyEngine.SetKeyBehaviour(Keys.Enter, CellEditCharacterBehaviour.CustomVerb1, CellEditAtEdgeBehaviour.CustomVerb1);
    

    CustomVerb1 basically means "no nothing special", which will allow the TextBox to process it.

    CellEditCharacterBehaviour.Ignore might look tempting too, but that means the key press will be ignored (hence the name) and even the TextBox will not see it.

     
  • David Harrison

    David Harrison - 2016-05-17

    Phillip, got it. It works a treat now. Thanks very much and congrats on such a wonderful piece of software to enhance the lazy old ListView control.

     

Log in to post a comment.

Auth0 Logo