Click here to Skip to main content
15,793,452 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I can't get the new value of the current cell of a DataGrid

private void dgBTLigne_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
            MessageBox.Show((dgBTLigne.SelectedItem as BTLigneDTO).Sujet);

I always get the old value.
Keith Barrow 26-Mar-11 5:28am    
You almost never need to get data from the the GUI in WPF. Binding is *much* easier. I suggest you google for "WPF databinding" and "WPF MVVM". The first, and most important thing to learn about WPF is is isn't winforms. The second if that it is *much* better than winforms.
Arun India 26-Mar-11 7:01am    
Me too agreed on that. Try to bind the DataGrid with an item source. The item source can be List, ObservableCollection etc. Also add the "INotifyPropertyChanged" to your class. So that you can also handle the changes in the datagrid.


1 solution

Data binding is the way to go.

There is a WPF data binding cheat sheet at[^]

You sould also read these CodeProject articles:

WPF Data Binding - Part 1[^]

A Guided Tour of WPF – Part 3 (Data binding)[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900