From ae53fb2c741063c6edf5197e5e40ff5ba20752a0 Mon Sep 17 00:00:00 2001 From: n-thony Date: Wed, 18 Oct 2023 16:48:42 +0300 Subject: [PATCH] added a condition to check if deleting last sheet --- instat/UserControls/DataGrid/ReoGrid/ucrReoGrid.vb | 7 +++++-- instat/ucrDataView.vb | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/instat/UserControls/DataGrid/ReoGrid/ucrReoGrid.vb b/instat/UserControls/DataGrid/ReoGrid/ucrReoGrid.vb index 34ffa33d754..c8c84549d30 100644 --- a/instat/UserControls/DataGrid/ReoGrid/ucrReoGrid.vb +++ b/instat/UserControls/DataGrid/ReoGrid/ucrReoGrid.vb @@ -139,8 +139,11 @@ Public MustInherit Class ucrReoGrid For i = grdData.Worksheets.Count - 1 To 0 Step -1 Dim iGridWorkheetsPosition As Integer = i 'Needed to prevent warning If _clsDataBook.DataFrames.Where(Function(x) x.strName = grdData.Worksheets(iGridWorkheetsPosition).Name).Count = 0 Then - grdData.RemoveWorksheet(i) - bDeleted = True + ' Check if we are deleting the last worksheet + If grdData.Worksheets.Count > 1 Then + grdData.RemoveWorksheet(i) + bDeleted = True + End If End If Next ' Force the grid to refresh if a sheet has been deleted as there is sometimes a UI problem otherwise. diff --git a/instat/ucrDataView.vb b/instat/ucrDataView.vb index 984a5f7fd4e..417be28f5bf 100644 --- a/instat/ucrDataView.vb +++ b/instat/ucrDataView.vb @@ -149,9 +149,9 @@ Public Class ucrDataView _clsDataBook.RefreshData() 'If we are updating one cell we do not need to refresh the grid and the 'refresh of that cell will be done manually - _grid.RemoveOldWorksheets() If Not bOnlyUpdateOneCell Then AddAndUpdateWorksheets() + _grid.RemoveOldWorksheets() If _clsDataBook.DataFrames.Count = 0 Then RefreshDisplayInformation() End If