C#中如何实现这样的效果? 一个listbox中循环添加项,添加完以后双击listbox中的项就可以记录下双击每个项的次数,显示在label中!其实就是做个小型的投票器,将侯选人添加到listbox中,双击侯选人名字,就可以记录他们的选票,不用数据库! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 定义一个按钮button1向listBox1中添加a b c d 分别放侯选人的次数 四个候选人 为ass ass01 ass02 ass03 private void button1_Click(object sender, EventArgs e) { if (this.comboBox1.Text != "") { this.listBox1.Items.Add(this.comboBox1.Text); } else { MessageBox.Show("请在列表中选择项目"); } if (this.comboBox1.Text == "ass") { a++; } if (this.comboBox1.Text == "ass01") { b++; } if (this.comboBox1.Text == "ass02") { c++; } if (this.comboBox1.Text == "ass03") { d++; } } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (this.listBox1.SelectedItem.ToString() == "ass") label1.Text = a.ToString(); if (this.listBox1.SelectedItem.ToString() == "ass01") label1.Text = b.ToString(); if (this.listBox1.SelectedItem.ToString() == "ass02") label1.Text = c.ToString(); if (this.listBox1.SelectedItem.ToString() == "ass03") label1.Text = d.ToString(); } xml 反序列化 子节点上移。 求助C#大牛!调用C++编译的dll数据类型转换的问题。 如何做com c#如何接收oracle包中返回的cursor类型数据? 讨论一个小小游戏外挂的问题 如何通过正则提取页面中<title></title>间信息 几个问题 ListView如何全选和全部不选??? c++中的char型在c#中如何读取啊? 新手上路!帮帮忙啊! sqlConnection 的精浅问题? 哪位有C#+SQL的数据库开发教程,100分感谢!
a b c d 分别放侯选人的次数
四个候选人 为ass ass01 ass02 ass03 private void button1_Click(object sender, EventArgs e)
{
if (this.comboBox1.Text != "")
{ this.listBox1.Items.Add(this.comboBox1.Text); }
else { MessageBox.Show("请在列表中选择项目"); }
if (this.comboBox1.Text == "ass")
{ a++; }
if (this.comboBox1.Text == "ass01")
{ b++; }
if (this.comboBox1.Text == "ass02")
{ c++; }
if (this.comboBox1.Text == "ass03")
{ d++; }
} private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.listBox1.SelectedItem.ToString() == "ass")
label1.Text = a.ToString();
if (this.listBox1.SelectedItem.ToString() == "ass01")
label1.Text = b.ToString();
if (this.listBox1.SelectedItem.ToString() == "ass02")
label1.Text = c.ToString();
if (this.listBox1.SelectedItem.ToString() == "ass03")
label1.Text = d.ToString();
}