using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 计算器
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//让选择加减乘除的不能改
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
textBox2.ReadOnly = true;
}
private void button1_Click(object sender, EventArgs e)
{
int i =int.Parse(textBox1.Text);
int j =int.Parse(textBox3.Text);
//获得combobox1的选中的索引
int k = comboBox1.SelectedIndex;
if (k==0)
{
textBox2.Text = (i + j).ToString();
}
if (k == 1)
{
textBox2.Text = (i - j).ToString();
}
if (k == 2)
{
textBox2.Text = (i * j).ToString();
}
if (k == 3)
{
textBox2.Text = (i / j).ToString();
}
if (k == 4)
{
textBox2.Text = (i % j).ToString();
}
}
}
}