Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1500
Undo changes within a cell in edit mode
posted

Hi,

I need to have a cell that will accept any input until it starts with A letter. If it starts with A letter the cell should remain in edit mode but any user input should not be written to the cell. That means the cell should have its value equal to A, be in edit mode and disregard all user character keyboard actions.

 Is there a simple way I can achieve this?

 Thanks,

Vitaly 

  • 2334
    posted

    You can handle the key events and check to see if the input starts with 'A'.  If so, cancel keyboard input, otherwise accept keyboard input.

     The event you want to look at is CellChange event.  If this does not do what you want you can consider using the KeyDown or KeyPress event of the grid.  However you will need to check if the ActiveCell is currently in Edit Mode before you process the key.

  • 1500
    posted

    Well, that can be done using SelStart, SetLength and SelText properties.