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
479
UltraGrid custom editors for masked input
posted

Hi all,

I've been cracking my head over the following:

I wanted a custom editor control for my ultragrid cells, that only allows the characters R, A, S, C and I in that order.  The user can enable/disable any of the characters by pressing the associated key on the keyboard.

So e.g. pressing R, A and  C would result in a string RA_C_ and pressing A, C and S after that would result in R_S__.

I tried to get this functionality done with a custom editor for the cell.
I subclassed the UltraTextEditor and tried to catch that control's KeyPress events.  However, that didn't work at all.  I could actually get the events, but the data traffic between the ultragrid cell and the editor went terribly wrong.

I finally tried using the KeyPress event of the ultragrid and that worked!  Instead of having all functionality in a separate user control, I put it in the ultragrid, and - although I don't like this kind of coding - I don't seem to be able to find another solution.

I hope I was able to help anyone struggling with the same problem.

PS: I was using v2009.1.