Prajakta
Prajakta

Reputation: 31

How to get previous value if entered value in cell of grid is removed

I have one data grid with 3 columns item_name, price and remarks.When I entered price in cell of grid and press tab then it's total is calculated by using datagrid_cellValueChange event. Now if I removed price and entered new value then how will I get the updated value?

Upvotes: 0

Views: 63

Answers (3)

Prajakta
Prajakta

Reputation: 31

Thank you both of you . I have got my answer. I have used datagrid_CellEntered event .

Upvotes: 0

Kate
Kate

Reputation: 1836

You might be able to do this without event handling.

Assuming your datagridview is bound to a datatable you can add a computed column that will perform the calculation automatically.

Here is some Microsoft documentation about it: DataColumn.Expression Property

Consider posting some code so we can assist further.

Upvotes: 0

Dhurgham_Fahem
Dhurgham_Fahem

Reputation: 1

I think you have to store the previews value as property of each object in your data source list. and you have to detect when the cell edit end to put the current value to the previews and put the new value to the current.

example :

Class A
{
public string PreviewsValue{ get; set; }
public string CurrentValue{ get; set; }
}

I hope this will help.

Upvotes: 0

Related Questions