/// <summary> /// Sets focus to TextBox_Contents on key press /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void spreadsheetPanel1_KeyPress(object sender, KeyPressEventArgs e) { TextBox_Contents.Focus(); if (e.KeyChar > 13) { TextBox_Contents.AppendText(e.KeyChar + ""); } }
/// <summary> /// Handles BeforeSelectionChangedEvents from the SpreadsheetPanel and fires UpdateCellEvent as needed /// </summary> /// <param name="e"></param> private void spreadsheetPanel1_BeforeSelectionChanged(MouseEventArgs e) { int col, row; spreadsheetPanel1.GetSelection(out col, out row); if (UpdateCellEvent != null) { UpdateCellEvent(col, row, TextBox_Contents.Text); } TextBox_Contents.Focus(); }
// Helper Methods: /// <summary> /// Updates the displayed values based on the selection /// </summary> /// <param name="ss"></param> private void DisplaySelection(SpreadsheetPanel ss) { int col, row; ss.GetSelection(out col, out row); string tmp = ((Convert.ToChar(col + 65)) + "" + (row + 1)); TextBox_CellName.Text = tmp; GetCellContentsEvent(tmp); TextBox_Contents.SelectAll(); }