private void _formatsView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (_isLoaded && e.RowIndex >= 0) { PaperFormat format = _formatsView.Rows[e.RowIndex].Tag as PaperFormat; string newName = _formatsView["NameColumn", e.RowIndex].Value != null ? _formatsView["NameColumn", e.RowIndex].Value.ToString() : string.Empty; float newWidth = 0.0f; if (_formatsView["WidthColumn", e.RowIndex].Value != null) { float.TryParse(_formatsView["WidthColumn", e.RowIndex].Value.ToString(), out newWidth); } float newHeight = 0.0f; if (_formatsView["HeightColumn", e.RowIndex].Value != null) { float.TryParse(_formatsView["HeightColumn", e.RowIndex].Value.ToString(), out newHeight); } int newDpi = 0; if (_formatsView["DpiColumn", e.RowIndex].Value != null) { int.TryParse(_formatsView["DpiColumn", e.RowIndex].Value.ToString(), out newDpi); } if (format != null) { format.Name = newName; format.Width = newWidth; format.Height = newHeight; format.Dpi = newDpi; } else { format = PriceManager.AddPaperFormat(newName, newWidth, newHeight, newDpi); _formatsView.Rows[e.RowIndex].Tag = format; } ValidateCells(null); } }