用visual studio 2010 c#编写窗体应用程序,实现在列表框中选择数字,点击等号,在listbox3中得出结果
左边两个 是listbox 右边是个textbox
按钮事件代码 如下:
private void button1_Click(object sender, EventArgs e)
{
if (this.listBox1.SelectedItem == null || this.listBox2.SelectedItem == null)
{
MessageBox.Show("请选择 减数或被减数");
return;
}
//MessageBox.Show(this.listBox1.SelectedItem.ToString());
int a=Convert.ToInt32(this.listBox1.SelectedItem.ToString());
int b=Convert.ToInt32(this.listBox2.SelectedItem.ToString());
this.textBox1.Text = (a - b).ToString();
}