diff --git a/PROMS/Volian.Controls.Library/DisplaySearch.Designer.cs b/PROMS/Volian.Controls.Library/DisplaySearch.Designer.cs index 14ff5c49..70dea6a5 100644 --- a/PROMS/Volian.Controls.Library/DisplaySearch.Designer.cs +++ b/PROMS/Volian.Controls.Library/DisplaySearch.Designer.cs @@ -1336,7 +1336,6 @@ namespace Volian.Controls.Library this.lbSrchResultsIncTrans.SelectedIndexChanged += new System.EventHandler(this.lbSrchResults_SelectedValueChanged); this.lbSrchResultsIncTrans.ItemClick += new System.EventHandler(this.lbSrchResultsIncTrans_ItemClicked); this.lbSrchResultsIncTrans.MouseMove += new System.Windows.Forms.MouseEventHandler(this.lbSrchResults_MouseMove); - this.lbSrchResultsIncTrans.ItemCheck += this.lbSrchResultsIncTrans_ItemChecked; // // panSearchButtons // diff --git a/PROMS/Volian.Controls.Library/DisplaySearch.cs b/PROMS/Volian.Controls.Library/DisplaySearch.cs index 91cd4afe..69ee55fa 100644 --- a/PROMS/Volian.Controls.Library/DisplaySearch.cs +++ b/PROMS/Volian.Controls.Library/DisplaySearch.cs @@ -1172,32 +1172,15 @@ namespace Volian.Controls.Library LastResultsMouseOverIndex = ResultsMouseOverIndex; } } - // B2021-003: random crash on lbSrchResultsIncTrans selection. Originally, only ItemClicked was used - // to track how many items in the list were checked. However, this gets called for both - // the clicked & checked events, so the count of checked items was not accurate (this count, - // IncTransSelectedCount was incremented/decremented when event occurred). The reason that the clicked - // event needs to be used is that the sender contains the bound item (proms item) but the checked - // event does not, so both are needed. The tracking of checked items is done to enable/disable - // the 'Convert Selected to Text' button. The fix was to flag from the ItemChecked event that the - // item was checked not just selected, so that the code in Clicked only runs for a check event. - private bool didcheck = false; - private void lbSrchResultsIncTrans_ItemChecked(object sender, EventArgs e) - { - didcheck = true; - } + // B2021-018: Removed code that was tracking the number of items checked in the incoming transition + // listbox. Found that could just look at the CheckedItems.Count value. (Previous fixes + // that were removed are B2021-003 & part of C2020-033 (part was for permissions, which was not removed) // C2020-033: lbSrchResultsIncTrans_ItemClicked is used to check permissions of a selection before allowing an // item to be clicked and to turn on/off the btnTranCvtSelToTxt button for converting selected to test. - // Two variables are used to keep track if items are checked in the list box: - // JustDidSelection - selecting an item event goes into both SelectedValueChanged & ItemClicked - // but need to keep track of itemclicked which is event for checking/unchecking of Incoming Transition - // items in lbSrchResultsIncTrans - // IncTransSelectedCount is used to keep track if any items are checked - private int IncTransSelectedCount = 0; - bool JustDidSelection = false; private void lbSrchResultsIncTrans_ItemClicked(object sender, EventArgs e) { ListBoxItem lbi = sender as ListBoxItem; - if (didcheck && lbi != null) + if (lbi != null) { ItemBindingData ibd = lbi.Tag as ItemBindingData; ItemInfo ii = ibd.DataItem as ItemInfo; @@ -1210,15 +1193,11 @@ namespace Volian.Controls.Library "Convert Transition to Text", MessageBoxButtons.OK, MessageBoxIcon.Information); lbi.CheckState = CheckState.Unchecked; } - else - if (!JustDidSelection) IncTransSelectedCount++; } - else - if (!JustDidSelection && IncTransSelectedCount > 0) IncTransSelectedCount--; // user unchecked an item - if (!JustDidSelection) btnTranCvtSelToTxt.Enabled = IncTransSelectedCount > 0; + // B2021-018: use the CheckedItems.Count on the list box for the search results for + // incoming transitions to determine whether to enable the convert selected to text: + btnTranCvtSelToTxt.Enabled = (lbSrchResultsIncTrans.CheckedItems.Count > 0); } - didcheck = false; - JustDidSelection = false; } private void GrpPanSearchResults_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { @@ -1240,7 +1219,6 @@ namespace Volian.Controls.Library lbSrchResultsIncTrans.Enabled = false; lbSrchResultsIncTrans.UseWaitCursor = true; } - JustDidSelection = true; ListBox mylb = sender as ListBox; // If the list is being refreshed, then set the selection index to -1 (no selection) @@ -1476,7 +1454,6 @@ namespace Volian.Controls.Library private void btnSearch_Click(object sender, EventArgs e) { - IncTransSelectedCount = 0; _fromLoad = false; DateTime start = DateTime.Now; Cursor savcursor = Cursor; @@ -2312,7 +2289,6 @@ namespace Volian.Controls.Library private bool _fromLoad = false; private void btnLoadSearchResults_Click(object sender, System.EventArgs e) { - IncTransSelectedCount = 0; _fromLoad = true; _LoadingList = true; ofdSearchResults.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS"; @@ -2713,7 +2689,7 @@ namespace Volian.Controls.Library // C2020-033: Update the search panel for Incoming transitions. This gets called from the tree view & the ribbon public void UpdateSearchIncTransResults() { - IncTransSelectedCount = 0; + //IncTransSelectedCount = 0; tabSearchTypes.SelectedTab = tabSearchTypes.Tabs[4]; lbSrchResultsIncTrans.DataSource = null;