private void Form1_Load(object sender, EventArgs e) { dataGridView1.Columns.Clear(); dataGridView1.Rows.Clear(); int i = 0; int j = 65; //ASCII 65 = 'A' int k = 0; while (j < 91) { dataGridView1.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = (Convert.ToChar(j)).ToString(), Name = i.ToString() }); j++; k++; } while (i < 50) { dataGridView1.Rows.Add(); dataGridView1.Rows[i].HeaderCell.Value = (i + 1).ToString(); i++; } SS = new spreadsheet(k, i); SS.CellPropertyChanged += SheetPropertyChanged; }
// Load Form private void Form1_Load(object sender, EventArgs e) { // Clear any existing Rows and Columns dataGridView1.Columns.Clear(); dataGridView1.Rows.Clear(); int Col = 0, Row = 0; // Initialize Columns and count number for (char i = 'A'; i <= 'Z'; i++) { dataGridView1.Columns.Add(new DataGridViewTextBoxColumn() { HeaderText = i.ToString(), Name = i.ToString() }); Col++; } // Initialize Rows and count number for (int a = 0; a < 50; a++) { dataGridView1.Rows.Add(); dataGridView1.Rows[a].HeaderCell.Value = (a + 1).ToString(); Row++; } // Use row and column counts to initialize spreadsheet CxR = new spreadsheet(Col, Row); CxR.CellPropertyChanged += Sheet_PropertyChanged; }
private void loadToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); string path = openFileDialog1.FileName; try { if (path != string.Empty) { CxR = new spreadsheet(26, 50); dataGridView1.SelectAll(); foreach (DataGridViewCell datacell in dataGridView1.SelectedCells) { datacell.Value = ""; } dataGridView1.ClearSelection(); CxR.CellPropertyChanged += Sheet_PropertyChanged; CxR.loadnewSS(path); } else { Console.WriteLine("Empty file"); } } catch (FileNotFoundException) { Console.WriteLine("File not found error"); } }
public float VNA() { spreadsheet HojaDeCalculo = new spreadsheet("EjercicioDictum2"); HojaDeCalculo.SetCell("A2", 100); HojaDeCalculo.Calculate(); return(HojaDeCalculo.GetCell("A4")); }