Hi,
How can I add a new row to the ultra grid which is already bound with a datatable.
I need to create a row by hitting the tab at the end of the row or enter key.
Thanks in advance.
Regards,
Arun
Hi Mike,
If you have multiple controls on a form....let us say a text field, combo, and a grid. If you use the tab key to move from the text field, to the combo, and then to the grid what you will notice is the grid will NOT receive focus when tabbed into. This only happens when the EditRow is at the bottom (TemplateOnBottom) of the grid and there are NO other rows in the grid.
Once you actually edit the grid and add at least one new REGULAR row like you did you can start tabbing through all the controls and the new row receives focus when the grid is tabbed into. If ONLY the EditRow exists the EditRow will not receive focus and it looks like the tab just didn't work.
-Ken
I'm not sure what more you are looking for. In fact, I'm still not sure I understand the issue. I'm wondering now if what you said about entering the control is important because the grid is not in edit mode at that point.
If that's the case, then you really just need to make sure there's a cell in edit mode when the grid's Enter event fires.
Are you saying that when you tab into the grid from another control and then press Tab again, focus leaves the grid immediately? Or are you saying that you are tabbing through the cells in the grid and it still doesn't add a new row?
Perhaps you could post a small sample project demonstrating the behavior you are getting and that would clear up the confusion.
If that's no good for your application, then you would have to somehow trap the Tab/Enter key (using KeyDown or maybe KeyPress on the grid) and try to detect if the focus is on the last row or last cell and then call the AddNew method on the band and then set the ActiveCell to a cell in the new row and use PerformAction to put that cell into edit mode.
The above suggestion was provided by you.
Could u suggest me how to do this ?
Hi Ken,
I'm afraid you lost me. Your original post asked about adding new rows to the grid when the user tabs at the end of a row. I tried this out with AllowAddNew set to TemplateOnBottom and 0 rows in the grid and it works just fine for me. I am attaching my sample project here so you can check it out.
kvillines said:If I init the collection with at least one item (one row + the addrow) then the grid accepts the Tab and enters the grid from the previous control.
Here's where you lost me. What do you mean by "enters the grid from the previous control"? I thought you were talking about tabbing within the grid. What does any other control or tabbing into the grid have to do with it?
This isn't working for me. I have a AllowAddNew set to TemplateOnBottom and when my collection is empty the grid ignores the Tab. If I init the collection with at least one item (one row + the addrow) then the grid accepts the Tab and enters the grid from the previous control.
Why is the Tab not working when the grid only has an AddRow?
Any help is appreciated.
thanks
-ken