Dont save new row items

This commit is contained in:
aj
2018-06-02 21:43:08 -04:00
parent 7c287e4bd4
commit b085bef9a7

View File

@@ -76,7 +76,12 @@ namespace CutToLength
private void Save() private void Save()
{ {
var json = JsonConvert.SerializeObject(items, Formatting.Indented); var itemsToSave = items;
if (dataGridView1.Rows[items.Count - 1].IsNewRow == true)
itemsToSave.RemoveAt(itemsToSave.Count - 1);
var json = JsonConvert.SerializeObject(itemsToSave, Formatting.Indented);
var saveFileDialog = new SaveFileDialog(); var saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Json File|*.json"; saveFileDialog.Filter = "Json File|*.json";