diff --git a/PROMS/Volian.Controls.Library/DisplayTags.cs b/PROMS/Volian.Controls.Library/DisplayTags.cs index 3e66ca32..9a6efda9 100644 --- a/PROMS/Volian.Controls.Library/DisplayTags.cs +++ b/PROMS/Volian.Controls.Library/DisplayTags.cs @@ -293,6 +293,7 @@ namespace Volian.Controls.Library { if (_Initalizing) return; EditItem topEditItem = MyEditItem; + MyEditItem.SaveContents(); FormatData fmtdata = CurItemInfo.ActiveFormat.PlantFormat.FormatData; string msgBox = null; if (cbChgAll.Checked) diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs index 80324ad6..381688d3 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.cs @@ -594,6 +594,7 @@ namespace Volian.Controls.Library this.SelectionChanged -= new EventHandler(StepRTB_SelectionChanged); this.ContextMenuStripChanged -= new EventHandler(StepRTB_ContextMenuStripChanged); this.RTBSelectionChanged -= new StepRTBEvent(StepRTB_RTBSelectionChanged); + this.HandleCreated -= new EventHandler(StepRTB_HandleCreated); this.HandleDestroyed -= new EventHandler(StepRTB_HandleDestroyed); _EventHandlersForKeyPress = _EventHandlersForKeyPress - 1; } @@ -619,9 +620,15 @@ namespace Volian.Controls.Library this.SelectionChanged +=new EventHandler(StepRTB_SelectionChanged); this.ContextMenuStripChanged += new EventHandler(StepRTB_ContextMenuStripChanged); this.RTBSelectionChanged += new StepRTBEvent(StepRTB_RTBSelectionChanged); + this.HandleCreated += new EventHandler(StepRTB_HandleCreated); this.HandleDestroyed += new EventHandler(StepRTB_HandleDestroyed); _EventHandlersForKeyPress = _EventHandlersForKeyPress+1; } + private int _HandleCount = 0; + void StepRTB_HandleCreated(object sender, EventArgs e) + { + _HandleCount++; + } // When a border style is changed, the richtextbox's handle is 'destroyed', so that the handleDestroyed // event is done. This was causing the event handlers to be removed (RemoveEventHandler) so that the // keypress event handler was not run. The following was added so that the keypress event is restored @@ -640,8 +647,12 @@ namespace Volian.Controls.Library } void StepRTB_HandleDestroyed(object sender, EventArgs e) { - Closed = true; - RemoveEventHandlers(); + if (_HandleCount == 0) + { + Closed = true; + RemoveEventHandlers(); + } + _HandleCount--; } void StepRTB_RTBSelectionChanged(object sender, EventArgs args) { diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.cs index e90d4ca8..d163012e 100644 --- a/PROMS/Volian.Controls.Library/StepTabRibbon.cs +++ b/PROMS/Volian.Controls.Library/StepTabRibbon.cs @@ -824,7 +824,7 @@ namespace Volian.Controls.Library // if doing the insert substep button, check for substeps already there and if so must match type. if (btn.Name == "btnInsSubstep") { - if (MyItemInfo.Steps != null) + if (MyItemInfo.Steps != null && MyItemInfo.Steps.Count > 0) { ItemInfo ichld = MyItemInfo.Steps[0]; btn.Click -= new System.EventHandler(btnInsStep_Click); @@ -843,7 +843,7 @@ namespace Volian.Controls.Library bool addit = true; StepData sd = MyItemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[sdr.Index]; int hlsSubType = -1; // if on hls, use this to set default on substep menu to first child - if (MyItemInfo.IsHigh && MyItemInfo.Steps != null) + if (MyItemInfo.IsHigh && MyItemInfo.Steps != null && MyItemInfo.Steps.Count > 0) { hlsSubType = (int)MyItemInfo.Steps[0].MyContent.Type - 20000; }