Fixed code for treeview select after selected step deleted

This commit is contained in:
Rich 2009-10-27 22:58:12 +00:00
parent d17c81a9d9
commit 37099ec443

View File

@ -264,15 +264,41 @@ namespace VEPROMS
/// <summary> /// <summary>
/// When the treeview is clicked - a timer is set /// When the treeview is clicked - a timer is set
/// This is done because the focus is returned to the treeview after the click event /// This is done because the focus is returned to the treeview after the click event
/// This approach did not work and was replaced with the code below.
/// The problem was that each time the treeview was clicked, the last selected node
/// was opened again, or the edit window was repositioned.
/// If the item was deleted and another treenode expanded, the click to expand the
/// node would cause the deleted node to be selected.
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void tv_Click(object sender, EventArgs e) //private void tv_Click(object sender, EventArgs e)
//{
//tv.Enabled = false;
//tmrTreeView.Enabled = true;
//}
/// <summary>
/// This opens nodes if the mouse is within the bounds of a node.
/// By using the timer, the focus can be passed to the edit window.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void tv_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{ {
tv.Enabled = false; if (e.Button != MouseButtons.Right)
tmrTreeView.Enabled = true; {
Point newPoint = new Point(e.X, e.Y);
VETreeNode tn = tv.GetNodeAt(newPoint) as VETreeNode;
// Check to make sure that a node has been selected and
// that the mouse is within the bounds of the node.
if (tn != null && tn.Bounds.Left < newPoint.X)
{
tv.SelectedNode = tn;
tv.Enabled = false;
tmrTreeView.Enabled = true;
}
}
} }
/// <summary> /// <summary>
/// This event is fired from the timer after the treeview click event completes /// This event is fired from the timer after the treeview click event completes
/// </summary> /// </summary>