PDA

View Full Version : مجموع ستون هاي DataGridView



sarbazi
دوشنبه 02 آذر 1388, 08:31 صبح
سلام دوستان من يك dataset دارم آن را به يك DataGridView ريختم حالا مي خواهم مجموع ستون خاص از DataGridView را برام بدهد مثل ستون سوم چه كار كنم
لطفا راهنماييم كنيد

shahab_ss
دوشنبه 02 آذر 1388, 08:53 صبح
private void Total()
{
double tot = 0;
int i = 0;
for (i = 0; i < dgv_1.Rows.Count; i++)
{
tot = tot + Convert.ToDouble(dgv_1.Rows[i].Cells["col_Name"].Value);

DataGridViewRowHeaderCell h = new DataGridViewRowHeaderCell();
h.Value = (i + 1).ToString();
dgv_Article.Rows[i].HeaderCell = h;

}

lbl_Tot.Text = tot > 0 ? String.Format("{0:0,0}", tot) : "0";

}