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.

Parents
  • 469350
    Suggested Answer
    Offline posted

    SabbeRubbish said:
    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.

    It's hard to offer advice here, since I'm not clear on exactly what went wrong.

    But, in NetAdvantage 2009 Vol 2., we added a new editor called the UltraControlContainerEditor. This new editor is a component which allows you to embed any control you want in a grid cell. So you could create a UserControl or a derived TextBox or even an UltraTextEditor that does what you want and embed that in a grid cell and that would give you a lot more control over the interaction between the grid and the editor. So you would be able to handle the values any way you like.

Reply Children