Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi Guys!
Need help with this:

Name------Unit-------Value
Kappa------kg----------1
Delta-------m-----------2
Alpha-------mm--------3

Now, I want to edit the Value on the datagridview, and everytime I enter a number I want to automatically calculated the other values. How can I do this? Need HELP!
Posted
Updated 10-Sep-14 3:14am
v2

1 solution

You need to take care of this in the collection that is bound to this grid, following these guidelines:

- Create a class A to hold the data for one row, and implement INotifyPropertyChanged on it
- Create another class that has the collection of A objects as a property
- Create each instance of class A, subscribe to the PropertyChanged event of it, and add to the collection
- Recalculate the values and update the items in the collection in your PropertyChanged event handler
- Implementing INotifyPropertyChanged should make sure that your grid is refreshed automatically when you bind the collection to it.
 
Share this answer
 
Comments
J3ssy Pmntra 10-Sep-14 9:40am    
I'm new at this. Perhaps you have some samples?
kbrandwijk 10-Sep-14 9:56am    
http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(v=vs.110).aspx contains sample code for creating a bindingcollection, and binding it to a gridview, using INotifyPropertyChanged. Try to use this as a starting point for your own code. You can update your question with your progress, so myself or others can help you further when you have additional questions.

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