From 95b663c89340cc32b912aa37b601e3ebefc44da7 Mon Sep 17 00:00:00 2001 From: AJ Date: Wed, 1 Oct 2025 23:09:00 -0400 Subject: [PATCH] SyncDocumentFromUI --- CutList/Forms/MainForm.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CutList/Forms/MainForm.cs b/CutList/Forms/MainForm.cs index c8c35de..599e939 100644 --- a/CutList/Forms/MainForm.cs +++ b/CutList/Forms/MainForm.cs @@ -105,6 +105,22 @@ namespace CutList.Forms } } + private void SyncDocumentFromUI() + { + if (currentDocument == null) + { + currentDocument = new Document(); + } + + // Flush any in-cell edits that haven’t committed yet. + dataGridView1.EndEdit(); + dataGridView2.EndEdit(); + + currentDocument.PartsToNest = parts.ToList(); // parts is the binding list + currentDocument.StockBins = bins.ToList(); // bins is the binding list + currentDocument.Tool = GetSelectedTool(); // whatever tool the user picked + } + private void LoadDocumentData() { parts = new BindingList(currentDocument.PartsToNest); @@ -122,6 +138,8 @@ namespace CutList.Forms private void Save() { + SyncDocumentFromUI(); + if (!currentDocument.Validate(out string validationMessage)) { MessageBox.Show(validationMessage, "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);