First, I would just like to say that the WPF data grid is great. I’ve only played with it for a couple of hours and I’m finding it incredibly easy to work with and very feature rich. After only a short time, I can load data from a database into the grid, add new items, make changes, and delete changes, and have all of these changes reflected in the database. Very little code and effort is required.
My question is, what is the best implementation of the grid from the user’s standpoint, in terms of when and how changes are saved. In a standard .Net grid, typically changes are made during row validation, when focus leaves the row. I know it’s standard, but this seems rather user unfriendly. Instead, I was thinking of using a save button, during which all updates are applied. If you add a row, make changes to any items, or delete any rows, none of it gets applied until the save button is pressed. Is this a generally appreciated method? If not, what would the best approach be to take?
Also, if the focus change/validation method is preferred, what is the best event to handle? I couldn’t really find an appropriate event on the DataGridControl object, nor the DataGridControlView object. And if the save method is the way to go, is there a way I can either commit or discard the insertion row before the save takes place? I’ve noticed my SQL to LINQ code blows up on the insertion row. It’s custom code, so I may not be accounting for something, but I get an IndexOutOfRangeException when I try to save that row, so I’d like to either skip it or make sure that it gets added to the list before I do the save. I could not find a way to do this either.
Imported from legacy forums. Posted by Mike Pateras (had 645 views)
As far as my save button problem goes, I found a solution, for the reference of anyone wondering about something similar. I grab a reference to the insertion row upon its initialization, and just before the save takes place, I call CancelEdit() on the insertion row.
Imported from legacy forums. Posted by Mike Pateras (had 1400 views)