diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.cs index b5741371..baaa4ea0 100644 --- a/PROMS/Volian.Controls.Library/StepTabRibbon.cs +++ b/PROMS/Volian.Controls.Library/StepTabRibbon.cs @@ -947,26 +947,35 @@ namespace Volian.Controls.Library /// If false cursor will be placed at the begining private void StartGridEditing(SelectionOption selOpt) { - if (MyFlexGrid != null && MyFlexGrid.Editor == null) + // Bug fix: B2012-203, B2012-204 + // Need to check if the selected table cell is in edit mode already. + // if already in edit mode, we don't want to do the StartEditing code below, because it + // will override the current cursor positioning and selection range. + Control ctrl = FindActiveControl(); + if (ctrl is VlnFlexGrid) { - MyFlexGrid.StartEditing(); - switch (selOpt) + // Selected table cell is not in edit mode. Go into edit mode and position acording + // to the pass in selOpt. + if (MyFlexGrid != null && MyFlexGrid.Editor == null) { - case SelectionOption.Start: - MyStepRTB.Select(0, 0); - break; - case SelectionOption.All: - MyStepRTB.SelectAll(); - break; - case SelectionOption.End: - break; - MyStepRTB.Select(MyStepRTB.TextLength, 0); - default: - MyStepRTB.Select(0, 0); - break; + MyFlexGrid.StartEditing(); + switch (selOpt) + { + case SelectionOption.Start: + MyStepRTB.Select(0, 0); + break; + case SelectionOption.All: + MyStepRTB.SelectAll(); + break; + case SelectionOption.End: + break; + MyStepRTB.Select(MyStepRTB.TextLength, 0); + default: + MyStepRTB.Select(0, 0); + break; + } } } - } public void btnInsPgBrk_Click(object sender, EventArgs e) { @@ -1050,18 +1059,25 @@ namespace Volian.Controls.Library } private Control FindActiveControl() { + // added the flag below because a table (grid) could have a cell selected (a control) + // but it might not have focus (in edit mode) + bool beenThereDoneThat = false; // flag to prevent infinate loop Control tmp = this; while (!(tmp.Parent is Form)) tmp = tmp.Parent; Form frm = tmp.Parent as Form; tmp = frm.ActiveControl; - while (tmp.Controls.Count > 0) + while (!beenThereDoneThat && tmp.Controls.Count > 0) + { + beenThereDoneThat = true; foreach (Control ctrl in tmp.Controls) if (ctrl.ContainsFocus) { tmp = ctrl; + beenThereDoneThat = false; break; } + } return tmp; } private void btnCut_Click(object sender, EventArgs e)