fixed use of Insert Symbol into a table cell and fixed bug where you could not select /copy a portion of table cell text

This commit is contained in:
John Jenko 2012-07-16 15:09:47 +00:00
parent 7bcfafcc8b
commit d13a0f0fb5

View File

@ -947,26 +947,35 @@ namespace Volian.Controls.Library
/// <param name="selectAll">If false cursor will be placed at the begining</param>
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)