Ejemplo n.º 1
0
        /// <summary>
        /// đọc và hiển thị data ma trận 2 lên
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRead2_Click(object sender, EventArgs e)
        {
            btnGetData2.Enabled = true;
            string[,] data;
            string padOpf = BusinessMaTrix.OpenFile();

            if (padOpf != null)
            {
                panel2.Controls.Clear();
                N = BusinessMaTrix.DocFile(padOpf).GetLength(0);
                P = BusinessMaTrix.DocFile(padOpf).GetLength(1);
                if (int.Parse(txtHang2.Text) != N)
                {
                    MessageBox.Show("File MaTran Không hợp lệ", "Lỗi");
                    return;
                }
                ;
                txtCot2.Text = P.ToString();
                data         = new string[N, P];
                getIn2       = new TextBox[N, P];
                data         = BusinessMaTrix.DocFile(padOpf);
                for (int i = 0; i < N; i++)
                {
                    for (int j = 0; j < P; j++)
                    {
                        getIn2[i, j]          = new TextBox();
                        getIn2[i, j].Location = new Point(20 + j * 45, 10 + i * 30);
                        getIn2[i, j].Size     = new System.Drawing.Size(40, 20);
                        getIn2[i, j].Text     = data[i, j].ToString();
                        Thread.Sleep(100);
                        panel2.Controls.Add(getIn2[i, j]);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// đọc và hiển thị data ma trận 1 lên
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRead1_Click(object sender, EventArgs e)
        {
            string[,] data;
            string padOpf = BusinessMaTrix.OpenFile();

            if (padOpf != null)
            {
                panel1.Controls.Clear();
                M             = BusinessMaTrix.DocFile(padOpf).GetLength(0);
                N             = BusinessMaTrix.DocFile(padOpf).GetLength(1);
                txtHang1.Text = M.ToString();
                txtCot1.Text  = N.ToString();
                txtHang2.Text = N.ToString();
                data          = new string[M, N];
                getIn1        = new TextBox[M, N];
                data          = BusinessMaTrix.DocFile(padOpf);
                for (int i = 0; i < M; i++)
                {
                    for (int j = 0; j < N; j++)
                    {
                        getIn1[i, j]          = new TextBox();
                        getIn1[i, j].Location = new Point(20 + j * 45, 10 + i * 30);
                        getIn1[i, j].Size     = new System.Drawing.Size(40, 20);
                        if (check1.Checked == true)
                        {
                            getIn1[i, j].Text = data[i, j].ToString();
                        }
                        Thread.Sleep(100);
                        panel1.Controls.Add(getIn1[i, j]);
                    }
                }
                if (getIn1 != null)
                {
                    btnGetData1.Enabled = true;
                }
            }
        }