How to change value of one cell onchange of other cell value in DataGridview

Sagar

For example: if I'm changing MRP column, it should multiply that value with another column value called No_of_Units and the result should be stored in column called Total, Thanks in advance

GuidoG

You mean something like this ?

private void DataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
    if (e.ColumnIndex == index of column MRP)
    {
        int value = (int)DataGridView1.Rows[e.RowIndex].Cells["NO_OF_UNITS"].Value * (int)DataGridView1.Rows[e.RowIndex].Cells["MRP"].Value;
        DataGridView1.Rows[e.RowIndex].Cells["TARGET_COLUMN"].Value = value;
    }
}

This answer is simplified, you might need some additional checks, like check on null values and that kind of stuff. But it should get you on your way.

In your comment you asked:

How to get the index of column MRP ?

Click on the datagrid. Find the property Columns and click on the little button in the list of columns, find the column MRP and copy the Name property. This could be MRP but it also be DataGridColumn1 or something.

Suppose the name property is 'MRP' than you can do:

if (e.ColumnIndex == MRP.ColumnIndex)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Change value in a cell based on value in another cell

From Dev

Change DataGridView Cell Value Programmatically

From Dev

Convert a DataGridView Cell Value into a DateTime

From Dev

SQL want to compare value in one cell with part of value in other cell

From Dev

How can i change color of particular row in datagridview, where a cell value is first timestamp of each day?

From Dev

DataGridView Cell Value Changing

From Dev

Change datagridview cell value in edit mode

From Dev

Change Cell Value if There is Overflow

From Dev

change cell in datagridview to empty value

From Dev

How to disable (make read only) a cell in a DataGridView CheckBox column based on the value in other cells?

From Dev

How to show next cell value when one cell is clicked in Datagridview in Messagebox

From Dev

How to get image value of Datagridview Image Cell

From Dev

C# DataGridView: How to change a single cell value

From Dev

How to add a row and change cell value in DataGridView from a different thread?

From Dev

How to Change Conditional Formatting of a Cell Based on a Change in the Cell Value

From Dev

How to get a value of a cell in datagridview devexpress

From Dev

DataGridView Cell Value Changing

From Dev

Jquery change table cell value if other cell contains word

From Dev

How to change cell value down one column into another but change the row value?

From Dev

How can I make a cell in Excel to change colour according to the value of other cell?

From Dev

Cell value change with Month

From Dev

How to get the first row corresponding cell value if i change the other rows cell value in kendo child grid

From Dev

Hiding a value in a datagridview cell

From Dev

How to change cell value repeatedly by entering the value in other cell or sheet?

From Dev

How to change background color of cell based on other cell value by VBA

From Dev

how to change cell values in datagridview according to a cell

From Dev

Change value of cell in Javascript

From Dev

how to make cell editable based on other cell value

From Dev

how to set value in 2 cell if other cell contains 'something'

Related Related

  1. 1

    Change value in a cell based on value in another cell

  2. 2

    Change DataGridView Cell Value Programmatically

  3. 3

    Convert a DataGridView Cell Value into a DateTime

  4. 4

    SQL want to compare value in one cell with part of value in other cell

  5. 5

    How can i change color of particular row in datagridview, where a cell value is first timestamp of each day?

  6. 6

    DataGridView Cell Value Changing

  7. 7

    Change datagridview cell value in edit mode

  8. 8

    Change Cell Value if There is Overflow

  9. 9

    change cell in datagridview to empty value

  10. 10

    How to disable (make read only) a cell in a DataGridView CheckBox column based on the value in other cells?

  11. 11

    How to show next cell value when one cell is clicked in Datagridview in Messagebox

  12. 12

    How to get image value of Datagridview Image Cell

  13. 13

    C# DataGridView: How to change a single cell value

  14. 14

    How to add a row and change cell value in DataGridView from a different thread?

  15. 15

    How to Change Conditional Formatting of a Cell Based on a Change in the Cell Value

  16. 16

    How to get a value of a cell in datagridview devexpress

  17. 17

    DataGridView Cell Value Changing

  18. 18

    Jquery change table cell value if other cell contains word

  19. 19

    How to change cell value down one column into another but change the row value?

  20. 20

    How can I make a cell in Excel to change colour according to the value of other cell?

  21. 21

    Cell value change with Month

  22. 22

    How to get the first row corresponding cell value if i change the other rows cell value in kendo child grid

  23. 23

    Hiding a value in a datagridview cell

  24. 24

    How to change cell value repeatedly by entering the value in other cell or sheet?

  25. 25

    How to change background color of cell based on other cell value by VBA

  26. 26

    how to change cell values in datagridview according to a cell

  27. 27

    Change value of cell in Javascript

  28. 28

    how to make cell editable based on other cell value

  29. 29

    how to set value in 2 cell if other cell contains 'something'

HotTag

Archive