Which column was edited?

Feb 5, 2009 at 9:33 AM
This is probably a very easy question for someone more experienced with this Datagrid, but I am just starting on it (although I used other ones in the past).

In the CellEditEnding event handler I want to do some validation, and this validation (obviously) depends on which cell the user was just editing. How can I find out which column was edited? The e.column doesn't tell me the column name property just the DisplayIndex, which may change.

This is probably a very basic question and I am probably overlooking something obvious, but it's been killing me for a day now....

Thanks for any help!!!

Feb 5, 2009 at 3:48 PM

Rather than validating in the CellEditEnding event, why not validate using the standard WPF binding validation mechanism? I provide a number of examples here:


Anyhow, the Column property on the DataGridCellEditEndingEventArgs is a DataGridColumn, not the display index - so it should provide what you are looking for.

Colin E.
http://www.scottlogic.co.uk/blog/wpf/ - my WPF blog
http://www.codeproject.com/KB/WPF/WPFDataGridExamples.aspx - WPF DataGrid Practical Examples

Feb 7, 2009 at 9:24 AM
Thanks Colin for the quick reply - unfortunately I had some other stuff of priority and couldn't continue working on this until now.

Yes, I have the DataGridColumn that was edited, but I don't know which property of the underlying data structure was edited.

Probably I wasn't clear in my original question, so let me add some more background info to it:
My datagrid is bound to a list of custom objects that I get from Linq. When I edit any of the fields, at validation I need to know which field the user changed.

About your page on validation: Thanks for it, I am going to check it out right now and will let you know if I find what I am looking for.

Thanks again