using System; using System.Windows.Forms; namespace MatrixToDataGridView { public partial class Form1 : Form { public Form1() { InitializeComponent(); for (int k = 0; k < 100; k++) { dataGridView1.TopLeftHeaderCell.Value = "Theta / Phi"; dataGridView1.Columns.Add("", k.ToString() );// dynamic cloumn adding dataGridView1.Rows.Add();//dynamic row adding } } public void function() { double [,] num = new double[100, 100]; //Populates the array for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { num[i, j] = i+j; } } //Populates the dataGridView1 for (int i = 0; i < 100; i++) { for (int j = 0; j < 100; j++) { dataGridView1.Rows[i].Cells[j].Value = num[i, j].ToString(); } } } //Button for calling the function() to populate the array num and dataGridView1 private void button1_Click(object sender, EventArgs e) { function(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)