how to change cell values in datagridview according to a cell

Muhammed Nihal

I have a datagridView in which there are predefined columns. Suppose there are four columns,let's say A,B,C and D. Column A is for quantity and Column B is for rate and Column C is for discount and Column D is for total.I need a textchanged event like thing for when i enter in Column C the value in Column D should automatically change according to calculation as D=A*B-C. So please advice me how to achieve this. Thank You.

private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1) 
{
    dataGridView1.Rows[e.RowIndex].Cells[14].Value =
    ((Convert.ToDecimal(dataGridView1.Rows[e.RowIndex].Cells[3].‌​Value)) * (Convert.ToDecimal(dataGridView1.Rows[e.RowIndex].Cells[7].V‌​alue)) 
    - Convert.ToDecimal(dataGridView1.Rows[e.RowIndex].Cells[13].V‌​alue));/*taxable*/ 
}
Iluvatar

If you want to change grid when some cell changed value, you can use CellEndEdit Event

like here:

private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
    {
        int editedRow = e.RowIndex;
        int editedColumn = e.ColumnIndex;

        int sum = 0;
        for (int i=0;i< dataGridView1.Columns.Count-1 ;i++)
            sum += dataGridView1[i, e.RowIndex];

        dataGridView1[dataGridView1.Columns.Count-1, editedRow] = sum;
    }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Datagridview Change cell color of non empty cell

From Dev

Change DataGridView Cell Value Programmatically

From Dev

How to change a formula according to cell value in excel?

From Dev

How to concatenate Datagridview rows values and store it into one datatable Cell

From Dev

datagridview cell mouse hover backcolor change

From Dev

Change datagridview cell value in edit mode

From Dev

Using cell values according to the time of the day

From Dev

Change dataGridView Cell Formatting on button click (not on cell click)

From Dev

change cell in datagridview to empty value

From Dev

How to delete a datagridview cell?

From Dev

How to Auto-size cell in datagridview according to data size

From Dev

change color of cell of dynamicly created datagridview

From Dev

How to display sum of 2 cell values in another cell and autorefresh it as cell values change in wxpython grid?

From Dev

comparison of datagridview cell values

From Dev

Change selected Treeview Node on Datagridview Cell Click

From Dev

Change datagridview cell background based on a external parameter

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 text of the top left cell of a datagridview?

From Dev

How to add a Cell programmatically to a DataGridView?

From Dev

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

From Dev

Change UINavigationbar title according to UICollectionView Cell

From Dev

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

From Dev

How to pass c# datagridview selected cell values to SQL query

From Dev

Change of the edited cell in a datagridview cell

From Dev

Change text of a cell on dataGridView_CellFormatting

From Dev

Datagridview checkbox cell change color of button and drawline

From Dev

VBA Change Colour of Cell According to the number of Cell Value

From Dev

Datagridview won't change cell color

Related Related

  1. 1

    Datagridview Change cell color of non empty cell

  2. 2

    Change DataGridView Cell Value Programmatically

  3. 3

    How to change a formula according to cell value in excel?

  4. 4

    How to concatenate Datagridview rows values and store it into one datatable Cell

  5. 5

    datagridview cell mouse hover backcolor change

  6. 6

    Change datagridview cell value in edit mode

  7. 7

    Using cell values according to the time of the day

  8. 8

    Change dataGridView Cell Formatting on button click (not on cell click)

  9. 9

    change cell in datagridview to empty value

  10. 10

    How to delete a datagridview cell?

  11. 11

    How to Auto-size cell in datagridview according to data size

  12. 12

    change color of cell of dynamicly created datagridview

  13. 13

    How to display sum of 2 cell values in another cell and autorefresh it as cell values change in wxpython grid?

  14. 14

    comparison of datagridview cell values

  15. 15

    Change selected Treeview Node on Datagridview Cell Click

  16. 16

    Change datagridview cell background based on a external parameter

  17. 17

    C# DataGridView: How to change a single cell value

  18. 18

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

  19. 19

    How to change text of the top left cell of a datagridview?

  20. 20

    How to add a Cell programmatically to a DataGridView?

  21. 21

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

  22. 22

    Change UINavigationbar title according to UICollectionView Cell

  23. 23

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

  24. 24

    How to pass c# datagridview selected cell values to SQL query

  25. 25

    Change of the edited cell in a datagridview cell

  26. 26

    Change text of a cell on dataGridView_CellFormatting

  27. 27

    Datagridview checkbox cell change color of button and drawline

  28. 28

    VBA Change Colour of Cell According to the number of Cell Value

  29. 29

    Datagridview won't change cell color

HotTag

Archive