Saturday 20 December 2014

How to Get Total Values From DataGridView Rows using Window Applicaton in C#



Total Values from DataGridView Row Values




Sum of DataGridViewRow Values For Loop in C#


                       DEMO





C# Coding


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QueryWindows
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            int total = 0;

            for (int i = 0; i < dataGridView1.RowCount; i++)
            {

                total += Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value);
            }

            txtOutput.Text = total.ToString();


        }
    }

}




First Create - New Window Form







































0 comments:

Post a Comment