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
285
Adding a new Row pressing the ENTER key
posted

Hi guys!

I came out with some code for achieving the title of this post, but I'm not really satisfied with how it looks. I'm pretty sure there's a better way of doing it.

 

Imagine you have the simplest grid possible. All you want to do is give the ability to the user to add multiple rows just by pressing Enter. The user clicks on the AddRow, enter some text and hit Enter, the focus should still be at the AddRow so the user can continuously enter new rows. How would you do that?

 

What I did is I subscribed to the KeyDown event and on enter I run:

this.PerformAction(UltraGridAction.AboveCell, false, false);

this.PerformAction(UltraGridAction.BelowCell, false, false);

The only problem with this is that as the new row doesn't get activated I don't get the text the user entered from the code. I can see it, but if I check grid.Rows[0].Cells["MyColName"].Value it's empty...
Please help me!! I have a huge queue of cases pending on this...
Thanks!