[C#] 纯文本查看 复制代码 private void frmTriangle_Load(object sender, EventArgs e)
{
double s1, s2, s3, trcir, trarea;
Triangle tri1 = new Triangle(0);
textBox1.Text = "0";
textBox2.Text = "0";
textBox3.Text = "0";
s1 = double.Parse(textBox1.Text);
s2 = double.Parse(textBox2.Text);
s3 = double.Parse(textBox3.Text);
trcir = tri1.triCir();
trarea = tri1.triArea();
textBox4.Text = trcir.ToString();
textBox5.Text = trarea.ToString();
if (tri1.SideA == tri1.SideB && tri1.SideB == tri1.SideC)
textBox6.Text = "等边三角形边长为:" + tri1.SideA + "厘米";
else
textBox6.Text = "三角形三边长分别为:" + tri1.SideA + "厘米" + tri1.SideB + "厘米" + tri1.SideC + "厘米";
}
你这个代码是正确的,错的是因为你的这个事件并没有和窗体绑定到一起,所以是不会执行的,不相信你双击一下窗体,还会出现一个Load事件,说明这个是无效的,你重新绑定一下Load事件就行了
方法是你双击窗体在出现的事件中写这些代码就行了
|