Money-去哪了每日站立会议

 

继昨天编写完善完代码后,又继续上次任务部分的编写,包含刷新计数,刷新金额求和,刷新消费情况总和,遍历Listview并删除项等,代码还未完善,明天继续。

 

private void button3_Click(object sender, EventArgs e)
{
//遍历Listview,选中的选项移除
for (int i = listView1.SelectedItems.Count - 1; i >= 0; i--)
{
ListViewItem item = listView1.SelectedItems[i];
listView1.Items.Remove(item);
}

//---------------------------刷新窗口----------------------------
//刷新计数
textBox1.Text = Convert.ToString(listView1.Items.Count);
//刷新金额求和
double MoneySum = 0;
for (int i = 0; i <= listView1.Items.Count - 1; i++)
{
ListViewItem Item = listView1.Items[i];
MoneySum += Convert.ToDouble(Item.SubItems[2].Text);
}
textBox2.Text = Convert.ToString(MoneySum);
//刷新消费情况总和
textBox3.Text = "0";
textBox4.Text = "0";
textBox5.Text = "0";
textBox6.Text = "0";
textBox7.Text = "0";
textBox8.Text = "0";
for (int i = 0; i <= listView1.Items.Count - 1; i++)
{
ListViewItem Item = listView1.Items[i];
if (listView1.Items[i].SubItems[1].Text == "日常用品")
textBox3.Text = (Convert.ToDouble(textBox3.Text) + Convert.ToDouble(listView1.Items[i].SubItems[2].Text)).ToString();
if (listView1.Items[i].SubItems[1].Text == "学习用品")
textBox4.Text = (Convert.ToDouble(textBox4.Text) + Convert.ToDouble(listView1.Items[i].SubItems[2].Text)).ToString();
if (listView1.Items[i].SubItems[1].Text == "话费")
textBox5.Text = (Convert.ToDouble(textBox5.Text) + Convert.ToDouble(listView1.Items[i].SubItems[2].Text)).ToString();
if (listView1.Items[i].SubItems[1].Text == "饮食")
textBox6.Text = (Convert.ToDouble(textBox6.Text) + Convert.ToDouble(listView1.Items[i].SubItems[2].Text)).ToString();
if (listView1.Items[i].SubItems[1].Text == "衣服")
textBox7.Text = (Convert.ToDouble(textBox7.Text) + Convert.ToDouble(listView1.Items[i].SubItems[2].Text)).ToString();
if (listView1.Items[i].SubItems[1].Text == "其他")
textBox8.Text = (Convert.ToDouble(textBox8.Text) + Convert.ToDouble(listView1.Items[i].SubItems[2].Text)).ToString();
}
}

private void button4_Click(object sender, EventArgs e)
{
listView1.BeginUpdate();//挂起
//遍历Listview并删除项
for (int i = listView1.Items.Count - 1; i >= 0; i--)
{
ListViewItem item = listView1.Items[i];
listView1.Items.Remove(item);
}
listView1.EndUpdate();//结束挂起
//---------------------------刷新窗口----------------------------
//刷新计数

 

posted @ 2018-12-07 22:46  阿木啊vov  阅读(108)  评论(0编辑  收藏  举报