两个多行文本框的产品并将其显示到另一个多行文本框

product of two multiline textboxes and display it also to another multiline textbox

我想知道如何进行计算,例如两个多行文本框的乘积,它的乘积也会显示在多行文本框中。 请看下面的设计

enter image description here

如果想得到两个多行文本框的乘积,并将结果显示在多行文本框中,可以使用如下代码:

private void textBox2_LostFocus(object sender, EventArgs e)
    {
        float a, b;
        for (int i = 0; i < textBox1.Lines.Length ; i++)
        {

            float.TryParse(textBox1.Lines[i], out a);
            float.TryParse(textBox2.Lines[i], out b);
            textBox3.AppendText((a * b).ToString()+ Environment.NewLine);
        }
    }

并且您必须在 Form1.Designer.cs 文件中添加事件处理程序:

        // 
        // textBox2
        // 
        this.textBox2.Location = new System.Drawing.Point(312, 110);
        this.textBox2.Multiline = true;
        this.textBox2.Name = "textBox2";
        this.textBox2.Size = new System.Drawing.Size(100, 167);
        this.textBox2.TabIndex = 4;
        this.textBox2.LostFocus += new System.EventHandler(this.textBox2_LostFocus);