public void TableMainGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { DataGridView senderDGV = sender as DataGridView; string tableDir = senderDGV.Name; string tableKey = DatabaseFunct.ConvertDirToTableKey(tableDir); Dictionary <int, Dictionary <string, dynamic> > tableData = DatabaseFunct.GetTableDataFromDir(tableDir) as Dictionary <int, Dictionary <string, dynamic> >; if (e.RowIndex > -1 && e.ColumnIndex > -1 && !DatabaseFunct.loadingTable) { //validate input of column type and return dynamic type var: dynamic val = ColumnTypes.ValidateCellInput(e, senderDGV); string displayVal = Convert.ToString(val); //don't want to trigger CellValueChanged a second time for checkboxes if (!(val is bool)) { Console.WriteLine("rewriting cell display to... " + Convert.ToString(val)); //corrected string value is applied to textbox senderDGV.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = displayVal; } //add data to database var colName = senderDGV.Columns[e.ColumnIndex].Name; var rowIndex = e.RowIndex; //apply to data tableData[rowIndex][colName] = val; Console.WriteLine("value of entry " + rowIndex + " of column \"" + colName + "\" changed to: " + displayVal); KeyValuePair <int, Dictionary <string, dynamic> > KVRow = new KeyValuePair <int, Dictionary <string, dynamic> >(rowIndex, tableData[rowIndex]); DatabaseFunct.UpdateStatusOfAllRowCellsInDisablerArrayOfCell(senderDGV, tableKey, KVRow, colName); } }