Hi, i have this datagridview containing column: {product, price, quantity, Total price}, and a 'calculate' button. I need to enter the quantity column and when I press 'calculate' button, it will calculate total price by price*quantity
what i am struggling now is how to grab the 'text' in "quantity" column, as i won't fill everything in it, maybe only one row.


product price quantity total price
topaz 100
emerald 400 4
gold 300 2

How to get the text in quantity? --> "4" and "2"
and i want to multiply it with the "price"


humm.. its easy.. if you want just the total price in Total price column..

do something like this

Dim i As Integer
        For i = 0 To Me.DataGridView1.Rows.Count - 2
            Me.DataGridView1.Rows(i).Cells(3).Value = Double.Parse(Me.DataGridView1.Rows(i).Cells(1).Value) * Double.Parse(Me.DataGridView1.Rows(i).Cells(2).Value)

here : Me.DataGridView1.Rows(i).Cells(1).Value = price
Me.DataGridView1.Rows(i).Cells(2).Value = quantity

i see

that really helps.

But i wonder in the loop, why it is Count - 2?
I think it should be Count - 1 right?

This question has already been answered. Start a new discussion instead.