HighTechTalks DotNet Forums  

TreeView Question

Dotnet Framework microsoft.public.dotnet.framework


Discuss TreeView Question in the Dotnet Framework forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Beringer
 
Posts: n/a

Default TreeView Question - 01-06-2005 , 03:19 AM






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));

}

}

}



Reply With Quote
  #2  
Old   
Nick Stansbury
 
Posts: n/a

Default Re: TreeView Question - 01-06-2005 , 09:37 AM






Hi,
Telerik have put a lot of work into a custom treeview - have a look
at www.telerik.com/radtreeview


"Beringer" <borden_eric (AT) invalid (DOT) com> wrote

Quote:
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));

}

}

}





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.