Click here to Skip to main content
15,905,682 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi I have a windows form containing a menu bar, tool strip and a DataGridView control. I am using Visual Studio 2008, C#.

I have a Select Button on the tool strip and a save menu item. I need To Update my datatable when i leave grid view and click on save Button. My problem is that if a cells value is changed and then either of the Select buttons is clicked, Table is not updated so the new value is not saved.

I have had a look at the events on the DataGridView such as the 'leave' event or cell value changed however none seem to do what I want. I.e. 'leave' or Cellvalue changed is not fired when i click on tool strip select Button

Does anyone know of a way I update my DataTabble when one of these buttons is clicked (or any other button).

Any help is greatly appreciated!
Posted
Comments
BillWoodruff 13-Nov-14 8:30am    
I think you need to provide details of how you are using databinding.
Sinisa Hajnal 13-Nov-14 8:42am    
Call Save function explicitely each time Select is clicked. You can check if the data changed before that so you avoid unnecessary DB calls.

1 solution

What it sounds like your running into is your not collecting the updated data grid values during the time you are in those steps. You may have to commit your update for the grid and then confirm your data grid values to save have been updated.

Data grids can be very tricky if your new to them, however if your using data binding you will need to call your data binding action again to update the values in your data binding for those updates to display.
 
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