Hey there.

I have 4 columns in a datagridviw

Description //// budget ///// Actual //// Difference


now the user can use the datagridview like normal, add different expenses and insert the budget and actual.
But now i have to calculate the difference between the budget and actual and insert it into the corresponding row.

What i thought is that i could just reverse this statement.

button1.Text = tblAllEntries.Rows[0].Cells[0].FormattedValue.ToString();

And then do this

tblAllEntries.Rows[0].Cells[3] = 'the Calculation i did (an integer)


But then i got this error
"Cannot implicitly convert type 'int' to System.windows.forms.Datagridviewcell"

Does any one have an idea what the code is to add a value to a Single cell programmatically?

Thank you
Ruan

tblAllEntries.Rows[0].Cells[3].Value = someThing.ToString(); //if the type of the column is not defined - by default is a type of string.

tblAllEntries.Rows[0].Cells[3].Value = someThing.ToString(); //if the type of the column is not defined - by default is a type of string.

That was Exactly what i wanted.

Thank you very Much Mitja

Have a great day!
Ruan

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