Hello
I have not found a deep explanation in the help files about the Template AddRow. What is it and what is it used for? What is the difference between IsAddRow and the IsTemplateAddRow properties?
Thanks a lot.
Hm, okay, I tried this out and I think I see what's happening. This probably has to do with the UpdateMode of the grid. By default, the grid updates and commits the changes to the current row OnCellChangeOrLostFocus. Since the grid is losing focus in this case, the grid is attempting to commit the changes to the current row. Since the current row in this instance is a TemplateAddRow with no changes, the row is cancelled.
One obvious way to get around this would be to set UpdateMode to OnCellChange.Of course, this means that the grid will no longer update when it loses focus, so you might want to put code in the Leave event of the grid and call grid.UpdateData if the ActiveRow is not the TemplateAddRow.
No the TemplateRow has not been edited and SyncWithCurrencyManager is set to false. The user doesn't not enter data into the grid directly, it is done through other form controls. Maybe changing some settings like RowUpdateCancelAction or UpdateMode will give the behavior I am looking for. Any ideas?
Thanks
Hi,
Has the TemplateAddRow been edited at all? If it has, then it's no longer a TemplateAddRow - it becomes an AddRow. My guess is that you have not edited it and when the grid loses focus, it's synchronizing it's position with that of the CurrencyManager. The only way to stop that would be to turn off SynchWithCurrencyManager. This might have other implications for your app, though, if you are relying on the grid and the CurrencyManager to be in synch.
Hi Mike,
I got a TemplateAddRow that I want to stay as the active row after the grid loses focus. At the moment, when the grid loses focus and the active row is the TemplateAddRow then the grid automatically selects the last "real" row in the grid. Is there anyway to prevent this behaviour from happening.
The main difference is that a TemplateAddRow is not a "real" row. It has no corresponding row in the data source of the grid. It's basically a dummy row that looks like a real row to the user. Once the user clicks on this row and begins editing, the grid will add a new row to it's underlaying DataSource and it becomes an AddRow - no longer a TemplateAddRow.