/// <summary> /// Event handler for the "open" menu item /// </summary> /// <param name="sender">Object sending event</param> /// <param name="e">Event arguments</param> private void openToolStripMenuItem_Click(object sender, EventArgs e) { //Found OpenFileDialog example from MSDN OpenFileDialog openFileDialog1 = new OpenFileDialog(); //Set the file extensions the open dialog shows openFileDialog1.Filter = "sprd files (*.sprd)|*.sprd|All files (*.*)|*.*"; //Show sprd files by default openFileDialog1.FilterIndex = 1; openFileDialog1.RestoreDirectory = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { try { //Update spreadsheet, clear, and then refresh the cell values, have to get saved version so that the versions match spreadSheet = new Spreadsheet(openFileDialog1.FileName, s => true, s => s.ToUpper(), spreadSheet.GetSavedVersion(openFileDialog1.FileName)); spreadsheetPanel1.Clear(); refreshSpreadsheet(new HashSet <string>(spreadSheet.GetNamesOfAllNonemptyCells())); //Make sure we erased the editedCell since no cells are edited now editedCell = ""; } catch (Exception ex) { MessageBox.Show("Error: Couldn't read file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } } }