B
Beringer
I am deriving my own TreeView control from the 1.0 Framework TreeView.
I have overriden the OnAfterSelect method and want to respond to selection
of a node.
The issue I am having is that if the user selects a node and then clicks the
node again, no OnAfterSelect event is triggered. I figure this is the way
it is supposed to work but would like to work around this.
Has anybody had this issue and found a way to work around it?
I thought I could monitor OnMouseUp events and see if the left mouse button
is clicked on the selected node and then call OnAfterSelect from with in
OnMouseUp.
This creates a new issue of when you actually do select another node, now
OnAfterSelect gets called twice (once for the select and once for the mouse
up event). Oh and in case your wondering, I'm pretty sure the OnAfterSelect
event is fired before the OnMouseUp event. A snipet of my code is shown
below:
protected override void OnAfterSelect(TreeViewEventArgs tvea)
{
base.OnAfterSelect(tvea);
...
do really cool stuff when node is selected!
...
}
protected override void OnMouseUp(MouseEventArgs mea)
{
base.OnMouseUp(mea);
if (mea.Button == MouseButtons.Left)
{
TreeNode node = GetNodeAt(mea.X, mea.Y);
if (node == this.SelectedNode)
{
OnAfterSelect(new TreeViewEventArgs(this.SelectedNode));
}
}
}
I have overriden the OnAfterSelect method and want to respond to selection
of a node.
The issue I am having is that if the user selects a node and then clicks the
node again, no OnAfterSelect event is triggered. I figure this is the way
it is supposed to work but would like to work around this.
Has anybody had this issue and found a way to work around it?
I thought I could monitor OnMouseUp events and see if the left mouse button
is clicked on the selected node and then call OnAfterSelect from with in
OnMouseUp.
This creates a new issue of when you actually do select another node, now
OnAfterSelect gets called twice (once for the select and once for the mouse
up event). Oh and in case your wondering, I'm pretty sure the OnAfterSelect
event is fired before the OnMouseUp event. A snipet of my code is shown
below:
protected override void OnAfterSelect(TreeViewEventArgs tvea)
{
base.OnAfterSelect(tvea);
...
do really cool stuff when node is selected!
...
}
protected override void OnMouseUp(MouseEventArgs mea)
{
base.OnMouseUp(mea);
if (mea.Button == MouseButtons.Left)
{
TreeNode node = GetNodeAt(mea.X, mea.Y);
if (node == this.SelectedNode)
{
OnAfterSelect(new TreeViewEventArgs(this.SelectedNode));
}
}
}