Пример #1
0
 private void button3_Click(object sender, EventArgs e)
 {
     cnt = 0;
     for (i = 0; i < n; i++)
     {
         for (j = 0; j < p; j++)
         {
             f = int.TryParse(LTB[cnt].Text.ToString(), out A[i, j]);
             if (f == false)
             {
                 break;
             }
             cnt++;
         }
         if (f == false)
         {
             break;
         }
     }
     cnt = 0;
     for (i = 0; i < p; i++)
     {
         for (j = 0; j < m; j++)
         {
             f1 = int.TryParse(LTB1[cnt].Text.ToString(), out B[i, j]);
             if (f1 == false)
             {
                 break;
             }
             cnt++;
         }
         if (f1 == false)
         {
             break;
         }
     }
     if (f == false || f1 == false)
     {
         MessageBox.Show("请输入正确的整数值");
     }
     else
     {
         Det.Matrix_Mul(A, B, C, n, p, m);
         x = x3 + 30; y = 90;
         for (i = 0; i < n; i++)
         {
             for (j = 0; j < m; j++)
             {
                 TextBox textbox = new TextBox();
                 textbox.Width    = 25;
                 textbox.Height   = 15;
                 textbox.Location = new Point(x, y);
                 LTB.Add(textbox);                               //加到控件列表中
                 textbox.TextAlign = HorizontalAlignment.Center; //数值居中
                 this.Controls.Add(textbox);                     //添加新控件
                 textbox.Text = C[i, j].ToString();
                 x           += 30;
             }
             x  = x3 + 30;
             y += 30;
         }
     }
     this.button3.Enabled = false;
 }