Click here to Skip to main content
16,016,227 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi Prof.

Lately I am working a project and I have a DataGridView that bind to a dataset in this way :

C#
ComponentsGvwDataset = new DataSet();
            da.Fill(ComponentsGvwDataset, "dtcomponents");
            ComponentsGvwChanges = new DataTable();
            ComponentsGvwChanges = ComponentsGvwDataset.Tables[0];
            this.GvwSearchGrid.DataSource = ComponentsGvwChanges;


, I need to get the changes in the data table once I finished changes any cells value with no need to go down one row to commit the changes in the DataGridView back into the data table, I tried many options with no luck, and any hint or help will highly appreciate.

Thanks in advance
Posted
Updated 31-Jul-12 3:47am
v5
Comments
Kenneth Haugland 31-Jul-12 6:18am    
WPF or WinForms? There is also something called accept changes in a table...
KahtaniM 31-Jul-12 7:43am    
thanks Kenneth , I tried accept changes ,but it doesn’t work , the Get changes() works with me when i change cell value and move down to a different row ,what I need is getting the changes immediately after Cell End Edit to do furthered checks.
Kenneth Haugland 31-Jul-12 7:48am    
Is it WPF or WinForms? Sounds like WPF but.... and add the tag too :)
KahtaniM 31-Jul-12 9:05am    
Yes Kenneth , it is Windows Forms.
Kenneth Haugland 31-Jul-12 9:07am    
Dont write WPF as a tag then ;)

1 solution

If I am understanding you correctly then the issue is that you cannot raise an event without exiting the cell.

There is a "CellValueChanged" event that is raised after you finish editing a cell (ie by pressing tab or enter or clicking off the cell etc).

In fact, if you create a separate thread to watch the cell value it does not know anything has changed until after you have left the cell in question.

So basically you are stuck having to leave the cell to get any updates.

IF you do not want to go down a row (ie continue editting different fields of the same row) but also send the latest data then you can attach to the CellEndEdit event and make the update manually. If this is the case then check out this MSDN entry
 
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