mihax
mihax
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
thanks for helping
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
is working
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
nicee
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
and how I remove the old?
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
so I need to remove the old then add the new one?
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
ohhh
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
and what I need to do to reset it
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
this is all the code
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
private void btnChange_Click(object sender, EventArgs e) { openFileDialog = new OpenFileDialog(); openFileDialog.Title = "Choose input"; openFileDialog.InitialDirectory = Environment.SpecialFolder.MyDocuments.ToString(); openFileDialog.Filter = "Text Files (*.in;*.txt)|*.in;*.txt|" + "All Files (*.*)|*.*"; ReadDataChange(); CreateGUI(); tbl.Update(); } private void ReadDataChange() { if (openFileDialog.ShowDialog() == DialogResult.OK) { pathFileName = openFileDialog.FileName; StreamReader sr = new StreamReader(pathFileName); string[] s; char[] sep = { ' ' }; string line = sr.ReadLine(); s = line.Split(sep, StringSplitOptions.RemoveEmptyEntries); n = int.Parse(s[0]); m = int.Parse(s[1]); H = new int[n + 1, m + 1]; c = new int[n + 1, m + 1]; int i = 0; while ((line = sr.ReadLine()) != null) { s = line.Split(sep, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < m; ++j) H[i, j] = int.Parse(s[j]); i++; if (i == n) break; } } }
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
one sec
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
no i have more
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
what u mean
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
but I choose the file and is not changing
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
and I want to have a button to choose another file and change the matrix
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
yea
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
then here I crate the matrix of buttons and display it on tablelayoutpanel
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
private void CreateGUI() { btn = new Button[n + 1, m + 1]; tbl = new TableLayoutPanel() { RowCount = n, ColumnCount = m, Dock = DockStyle.Fill }; int W = panel.Width; int H1 = panel.Height; L = Math.Min(H1, W) / Math.Max(n, m); for (int j = 0; j < m; ++j) tbl.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, L)); for (int i = 0; i < n; ++i) { tbl.RowStyles.Add(new RowStyle(SizeType.Percent, L)); for (int j = 0; j < m; ++j) { btn[i, j] = new Button() { Dock = DockStyle.Fill, BackColor = Color.Yellow, Text = H[i, j].ToString(), ForeColor = Color.Black, Font = new Font("Arial", 14), Margin = new Padding(0), FlatStyle = FlatStyle.Flat }; tbl.Controls.Add(btn[i, j], j, i); } } panel.Controls.Add(tbl); }
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
what u mean
62 replies
CC#
Created by mihax on 5/17/2023 in #help
❔ Matrix dynamic allocation
yes I know sorry for that is from school
62 replies