I have a grid with rows of data, as well as 2 rows with buttons to add different types of items to the data behind the grid.
When the button is clicked, the event fires to show a dialog box collecting certain information. Once the information is entered, the dialog box is closed, the data is updated. The grid refreshes appropriately and an iteration of the rows results in finding the newly added row.
I want to scroll this new row into view, activate a cell and enter edit mode for that cell.
Unfortunately, none of the desired actions occur and the grid stays with the cell I clicked as the active cell. I'm assuming this somehow has to do with the fact that it is called from a button click within the grid, rather than from a toolbar. Is there some way to call the actions after the clickcellbutton is completed?
These are the actions called after the new row is found:
UltraGrid1.ActiveRowScrollRegion.ScrollRowIntoView(row) UltraGrid1.ActiveRow = row UltraGrid1.ActiveCell = row.Cells("Low")
UltraGrid1.PerformAction(UltraGridAction.EnterEditMode)
I appreciate any assistance that can be provided.
Thank you both so much. It is now resolved.
FYI, I was trying to enter edit mode on a row that was filtered out and that was the issue behind the problem. I was mistakenly assuming I was only iterating through visible rows in the ultragrid. I had tried BeginInvoke previously and it was not working. Understandably why...
Thanks again!
My guess is that you are right and this is some kind of timing issue. Maybe since you are clicking on a button inside a cell, the cell is still in the process of entering edit mode or processing the click and so you either cannot change the ActiveRow/Cell or you are changing it successfully, but then it's getting set back.
You can often get around issues like this using a BeginInvoke to call a method instead of calling the code from directly inside the event handler.
Hello,
You should first to perform UltraGrid to exits of edit mode, also it is good to put your code in BeginUpdate()/EndUpdate() block. Please see attached sample and let me know if it works for you.
Please let me know if you have any further questions.