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 Arun,
The easiest thing to do would be to use the AllowAddNew property on the grid.DisplayLayout.Override. You could set it to TemplateOnBottom and that would give the user an AddNewRow that they could simply tab into.
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.
Hi Mike,
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
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
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?