public Form1() { //setting datagrid properties InitializeComponent(); dataGridView1.ColumnCount = 26; dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView1.RowCount = 50; dataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders; // default header style for now //generate column names for (int i = 0; i < dataGridView1.ColumnCount; i++) { dataGridView1.Columns[i].Name = Convert.ToChar(65 + i).ToString(); } //generate row headers for (int i = 1; i <= dataGridView1.RowCount; i++) { dataGridView1.Rows[i - 1].HeaderCell.Value = (i).ToString(); } Sheet = new CptS321.Spreadsheet(dataGridView1.RowCount, dataGridView1.ColumnCount); //if CellPropertyChanged event is fired, UpdateCell is called //"Subscribing" to this Spreadsheet's CellPropertyChanged event Sheet.CellPropertyChanged += UpdateCell; textBox1.LostFocus += textBoxFocusLost; textBox1.GotFocus += textBoxFocusGot; selectedCell = Sheet.GetCell(0, 0); }
public void TestSpreadsheet() { // Test that the Bounds of the Spreadsheet are within the Requirements CptS321.Spreadsheet spreadsheet = new CptS321.Spreadsheet(10, 10); Assert.That(spreadsheet.RowCount >= 1 && spreadsheet.RowCount <= 100); Assert.That(spreadsheet.ColumnCount >= 1 && spreadsheet.ColumnCount <= 100); // Test that trying to access a cell outside the array throws an error Assert.Throws <IndexOutOfRangeException>(() => spreadsheet.GetCell(10, 11)); }
/// <summary> /// Initializes a new instance of the <see cref="Form1"/> class. /// Spreadsheet Application /// </summary> public Form1() { this.InitializeComponent(); // Expand Header Cells to Show Full Number this.dataGridView.RowHeadersWidth = 50; // Construct a new Spreadsheet Object and Subscribe to Spreadsheet Changes this.spreadsheet = new CptS321.Spreadsheet(50, 26); this.spreadsheet.CellPropertyChanged += this.UpdateFormUI; // this.dataGridView.CellBeginEdit this.dataGridView.CellBeginEdit += this.dataGridView_CellBeginEdit; this.dataGridView.CellEndEdit += this.dataGridView_CellEndEdit; }
public void TestEngine() { CptS321.Spreadsheet spreadsheet = new CptS321.Spreadsheet(100, 100); }