String projectfliter=null;
private void toolStripComboBox2_DropDownClosed(object sender, EventArgs e)
{
projectfliter = toolStripComboBox2.SelectedItem.ToString();
DataSet da = new DataSet();
da.ReadXml("Your Data Source Local");
DataView dv = da.Tables[0].DefaultView;
dv.RowFilter = string.Format("ProjectName='{0}'", projectfliter.ToString());
dataGridView1.DataSource = da.Tables[0].DefaultView;
int count = dataGridView1.RowCount;
Double text = 0;
for (int b = 0; b < count; b++)
{
string value = Convert.ToString(dataGridView1.Rows[b].Cells[2].Value);
if (!string.IsNullOrEmpty(value))
{
text += Double.Parse(value);
}
}
uhours = text.ToString();
dataGridView1.DataSource = 0;
System.Data.DataTable dt = new System.Data.DataTable();
dt = dv.ToTable();
DataRow dr = dt.NewRow();
dr[0] = " ";
dr[1] = "Totals:";
dr[2] = uhours;
dt.Rows.Add(dr);
uhours = null;
dataGridView1.DataSource = dt;
}