我现在想了一个笨办法方法如下:
private void textBox7_TextChanged(object sender, EventArgs e)
{
double x, z, a, k, i, wkx, h, wx, W, invA, m;
x = Convert.ToDouble(this.textBox1.Text.Trim());
z = Convert.ToDouble(this.textBox2.Text.Trim());
a = Convert.ToDouble(this.textBox3.Text.Trim());
m = Convert.ToDouble(this.textBox4.Text.Trim());
invA = Convert.ToDouble(textBox7.Text);
i = (a / 180 * z) + (0.5) + (2 * x * (1 / Math.Tan(a))) / 3.14;
k = Math.Round(i, 0, MidpointRounding.AwayFromZero);
h = (Math.PI * (k - 0.5)) + z * invA;
wkx = 1 / Math.Tan(a) * h;
wx = 2 * x * Math.Sin(a);
W = (wkx + wx) * m;
this.textBox5.Text = Convert.ToString(k);
this.textBox6.Text = Convert.ToString(W);
}
private void button1_Click(object sender, EventArgs e)
{
double x, z, a, k, i, wkx, h, wx, W, invA, m;
x = Convert.ToDouble(this.textBox1.Text.Trim());
z = Convert.ToDouble(this.textBox2.Text.Trim());
a = Convert.ToDouble(this.textBox3.Text.Trim());
m = Convert.ToDouble(this.textBox4.Text.Trim());
k = Convert.ToDouble(textBox5.Text);
invA = Convert.ToDouble(textBox7.Text);
i = (a / 180 * z) + (0.5) + (2 * x * (1 / Math.Tan(a))) / 3.14;
h = (Math.PI * (k - 0.5)) + z * invA;
wkx = 1 / Math.Tan(a) * h;
wx = 2 * x * Math.Sin(a);
W = (wkx + wx) * m;
this.textBox5.Text = Convert.ToString(k);
this.textBox6.Text = Convert.ToString(W);
}
意思就是再往输入框里输入数字的时候把k先算出来,当我改了k以后再按butteon让他计算,不过有个缺点,必须是把四个框里的数字按顺序输入,否则出错,而且不方便,各位有没有更好的办法,谢谢了