FlexGrid - Adding and Editing Rows

Posted by: mwebster on 11 February 2020, 6:26 am EST

    • Post Options:
    • Link

    Posted 11 February 2020, 6:26 am EST

    I am having some trouble making sense of how to allow a user to easily add/edit rows in a Flex Grid. Basically, I need the FlexGrid to remain in edit mode until the user Hits “Enter” or otherwise exits the row being added/edited. They need to be able to tab between or use left/right arrow keys to move between columns without exiting edit mode. I need to identify whey they have hit the “Enter” key in order to then exit edit mode so that I can then handle the new row or the changes made to an existing row.

    The problem is that the AfterEdit event fires every time the user exits a column. PreserveEditMode does not seem to do anything and even if it did, I don’t know how how to identify when the “Enter” key is pressed to then exit edit mode and trigger the AfterEdit event.

    I have no problem identifying which row was edited using the e.Row value but without being able to allow the user to edit multiple columns and then deliberately exit edit mode by hitting “Enter” or exiting the row being edited, I am stuck.

    Thanks,

    Mike

  • Posted 12 February 2020, 4:10 pm EST

    Hi Mike,

    Kindly allow me to summarize your requirements:

    1. Move focus to next cell when Tab/arrow keys are pressed.
    2. While changing cells, they should remain in edit mode.
    3. Entering Enter key/clicking current/other row should end editing. Also, notify that the Enter key is pressed.

    To meet the above requirements, following are solutions:

    1. Use the KeyActionTab property and set it to MoveAcross/MoveAcrossOut. This property specifies the action to follow when Tab key is pressed.
    2. Use PreserverEditMode property and set it to True. This property specifies to stay in edit mode when changing the cells.
    3. With above two properties set, pressing Enter key/clicking any row will itself end editing.

      However, handling the keyboard events like PreviewKeyPress etc will not notify when Enter key is pressed. This is because these don’t work in edit mode.

      To get notification when Enter key is pressed in edit mode, you should handle the SetupEditor event, store the flexgrid’s Editor (of type Control) and handle its PreviewKeyDown event.

    Please find attached a sample application for reference.

    Thanks,

    Ruchir

    AddEditRow_C1FlexGWinF.zip

  • Posted 12 February 2020, 11:30 pm EST

    Thanks!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels