示例#1
0
        private void DataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            //Update underlying spreadsheet when a cell in the DataGrid is getting validated
            DataGridView mainGrid = sender as DataGridView;

            if (e.RowIndex < 0 | e.ColumnIndex < 0)
            {
                return;
            }
            if (mainGrid.CurrentCell.Value is null)
            {
                return;
            }
            string text = mainGrid.CurrentCell.Value.ToString();

            if (text.Length == 0)
            {
                return;
            }
            //Update underlying spreaqdsheet cell with value entered into UI. Underlying spreadsheet will do
            //logic to determine what to do with the entered text.

            spreadSheetApp.GetCell(e.RowIndex, e.ColumnIndex).Text = mainGrid[e.ColumnIndex, e.RowIndex].Value.ToString();
        }
示例#2
0
 // Event for when stuff in the datagridview cell is being changed
 private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
 {
     // Sets the text of the datagridview cell to the text of the spreadsheetcell
     dataGridView1[e.ColumnIndex, e.RowIndex].Value = spreadsheet.GetCell(e.RowIndex, e.ColumnIndex).Text;
 }