I tried to calculate the total of the column named QTY in the datagridview.
But I coul not.My code is below. Could you help me , please?
public int RowCount { get; set; }
[BrowsableAttribute(false)]
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
private void UpdateLabelText()
{
int QtyTotal = 0;
int counter;
// Iterate through all the rows and sum up the appropriate columns.
for (counter = 0; counter < (dataGridView1.Rows.Count);
counter++)
{
if (dataGridView1.Rows[counter].Cells["Qty"].Value
!= null)
{
if (dataGridView1.Rows[counter].
Cells["Qty"].Value.ToString().Length != 0)
{
QtyTotal += int.Parse(dataGridView1.Rows[counter].
Cells["Qty"].Value.ToString());
}
}
}
// Set the labels to reflect the current state of the DataGridView.
label17.Text = "Qty Total: " + QtyTotal.ToString();
}