470,586 Members | 1,349 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,586 developers. It's quick & easy.

TreeView node...

Tim
Hi

I have a form with a treeview on it. When I select a particular node it
adds/shows a tab on the form. The treeview node remains selected as it
should. The user can close the tab or remove the focus to another tab.

Clicking on the same already selected node should add/show the tab, however
the after select event does not fire as the node is already selected. I
trapped the click event of the treeview but that is not node specific. In
the code I have a variable to remember the current node.

When I fire the click event it works great if the user clicks on the same
node, if they click on another node I have no way of telling as the click
event happens before the after select.

So if the user clicks NodeA it opens tab. NodeA is retained in memory as
current node. If the user closes the tab and then clicks on NodeA again it
works great because NodeA is in a variable. But if the user clicks NodeB
then the tab for NodeA opens because NodeA is the current node and the click
event happens before the after select event which will then fire the code
for NodeB.

How can I solve this issue?

Tim
Nov 17 '05 #1
6 6494
While the Click event does not provide you with an EventArg that specifies
the currently selected node... the TreeView itself will tell you... When the
Click event fires, check the SelectedNode property of the TreeView to
determine which node is currently selected.

Brendan
"Tim" wrote:
Hi

I have a form with a treeview on it. When I select a particular node it
adds/shows a tab on the form. The treeview node remains selected as it
should. The user can close the tab or remove the focus to another tab.

Clicking on the same already selected node should add/show the tab, however
the after select event does not fire as the node is already selected. I
trapped the click event of the treeview but that is not node specific. In
the code I have a variable to remember the current node.

When I fire the click event it works great if the user clicks on the same
node, if they click on another node I have no way of telling as the click
event happens before the after select.

So if the user clicks NodeA it opens tab. NodeA is retained in memory as
current node. If the user closes the tab and then clicks on NodeA again it
works great because NodeA is in a variable. But if the user clicks NodeB
then the tab for NodeA opens because NodeA is the current node and the click
event happens before the after select event which will then fire the code
for NodeB.

How can I solve this issue?

Tim

Nov 17 '05 #2
I apologize, I misread some of what you said before replying... Click doesn’t
always occur after BeforeSelect or AfterSelect.

Brendan
"Brendan Grant" wrote:
While the Click event does not provide you with an EventArg that specifies
the currently selected node... the TreeView itself will tell you... When the
Click event fires, check the SelectedNode property of the TreeView to
determine which node is currently selected.

Brendan
"Tim" wrote:
Hi

I have a form with a treeview on it. When I select a particular node it
adds/shows a tab on the form. The treeview node remains selected as it
should. The user can close the tab or remove the focus to another tab.

Clicking on the same already selected node should add/show the tab, however
the after select event does not fire as the node is already selected. I
trapped the click event of the treeview but that is not node specific. In
the code I have a variable to remember the current node.

When I fire the click event it works great if the user clicks on the same
node, if they click on another node I have no way of telling as the click
event happens before the after select.

So if the user clicks NodeA it opens tab. NodeA is retained in memory as
current node. If the user closes the tab and then clicks on NodeA again it
works great because NodeA is in a variable. But if the user clicks NodeB
then the tab for NodeA opens because NodeA is the current node and the click
event happens before the after select event which will then fire the code
for NodeB.

How can I solve this issue?

Tim

Nov 17 '05 #3
"Tim" <ti*@home.com> wrote in message
news:hM*******************@news20.bellglobal.com.. .
I have a form with a treeview on it. When I select a particular node it
adds/shows a tab on the form. The treeview node remains selected as it
should. The user can close the tab or remove the focus to another tab.

Clicking on the same already selected node should add/show the tab,
however the after select event does not fire as the node is already
selected. I trapped the click event of the treeview but that is not node
specific. In the code I have a variable to remember the current node.

When I fire the click event it works great if the user clicks on the same
node, if they click on another node I have no way of telling as the click
event happens before the after select.

So if the user clicks NodeA it opens tab. NodeA is retained in memory as
current node. If the user closes the tab and then clicks on NodeA again it
works great because NodeA is in a variable. But if the user clicks NodeB
then the tab for NodeA opens because NodeA is the current node and the
click event happens before the after select event which will then fire the
code for NodeB.

How can I solve this issue?


What's about the SelectedNode property on the tree?
Nov 17 '05 #4
That was my thought earlier as well... only I was sadly mistaken.

The trick with SelectedNode is knowing when to check it... and doing so on
the Click event does not always yield the desired outcome as order of the
events is Click, BeforeSelect and AfterSelect. This is problematic for him
because SelectedNode is changed between BeforeSelect and AfterSelect.

Brendan
"Danny Tuppeny" wrote:
"Tim" <ti*@home.com> wrote in message
news:hM*******************@news20.bellglobal.com.. .
I have a form with a treeview on it. When I select a particular node it
adds/shows a tab on the form. The treeview node remains selected as it
should. The user can close the tab or remove the focus to another tab.

Clicking on the same already selected node should add/show the tab,
however the after select event does not fire as the node is already
selected. I trapped the click event of the treeview but that is not node
specific. In the code I have a variable to remember the current node.

When I fire the click event it works great if the user clicks on the same
node, if they click on another node I have no way of telling as the click
event happens before the after select.

So if the user clicks NodeA it opens tab. NodeA is retained in memory as
current node. If the user closes the tab and then clicks on NodeA again it
works great because NodeA is in a variable. But if the user clicks NodeB
then the tab for NodeA opens because NodeA is the current node and the
click event happens before the after select event which will then fire the
code for NodeB.

How can I solve this issue?


What's about the SelectedNode property on the tree?

Nov 17 '05 #5
Assuming tvChild is your TreeView control,

private void tvChild_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
tnClickedOn = tvChild.GetNodeAt(e.X, e.Y);
}

Thus tnClickedOn will always be the last node that the user clicked
on... Of course, you will need to define tnClickedOn in a scope such
that it will be visible to everything that needs to use it.

Hope this helps,

JB

Brendan Grant wrote:
That was my thought earlier as well... only I was sadly mistaken.

The trick with SelectedNode is knowing when to check it... and doing so on
the Click event does not always yield the desired outcome as order of the
events is Click, BeforeSelect and AfterSelect. This is problematic for him
because SelectedNode is changed between BeforeSelect and AfterSelect.

Brendan
"Danny Tuppeny" wrote:
"Tim" <ti*@home.com> wrote in message
news:hM*******************@news20.bellglobal.com.. .
I have a form with a treeview on it. When I select a particular node it
adds/shows a tab on the form. The treeview node remains selected as it
should. The user can close the tab or remove the focus to another tab.

Clicking on the same already selected node should add/show the tab,
however the after select event does not fire as the node is already
selected. I trapped the click event of the treeview but that is not node
specific. In the code I have a variable to remember the current node.

When I fire the click event it works great if the user clicks on the same
node, if they click on another node I have no way of telling as the click
event happens before the after select.

So if the user clicks NodeA it opens tab. NodeA is retained in memory as
current node. If the user closes the tab and then clicks on NodeA again it
works great because NodeA is in a variable. But if the user clicks NodeB
then the tab for NodeA opens because NodeA is the current node and the
click event happens before the after select event which will then fire the
code for NodeB.

How can I solve this issue?


What's about the SelectedNode property on the tree?


Nov 17 '05 #6
Assuming tvChild is your TreeView control,

private void tvChild_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
tnClickedOn = tvChild.GetNodeAt(e.X, e.Y);
}

Thus tnClickedOn will always be the last node that the user clicked
on... Of course, you will need to define tnClickedOn in a scope such
that it will be visible to everything that needs to use it.

Hope this helps,

JB

Brendan Grant wrote:
That was my thought earlier as well... only I was sadly mistaken.

The trick with SelectedNode is knowing when to check it... and doing so on
the Click event does not always yield the desired outcome as order of the
events is Click, BeforeSelect and AfterSelect. This is problematic for him
because SelectedNode is changed between BeforeSelect and AfterSelect.

Brendan
"Danny Tuppeny" wrote:
"Tim" <ti*@home.com> wrote in message
news:hM*******************@news20.bellglobal.com.. .
I have a form with a treeview on it. When I select a particular node it
adds/shows a tab on the form. The treeview node remains selected as it
should. The user can close the tab or remove the focus to another tab.

Clicking on the same already selected node should add/show the tab,
however the after select event does not fire as the node is already
selected. I trapped the click event of the treeview but that is not node
specific. In the code I have a variable to remember the current node.

When I fire the click event it works great if the user clicks on the same
node, if they click on another node I have no way of telling as the click
event happens before the after select.

So if the user clicks NodeA it opens tab. NodeA is retained in memory as
current node. If the user closes the tab and then clicks on NodeA again it
works great because NodeA is in a variable. But if the user clicks NodeB
then the tab for NodeA opens because NodeA is the current node and the
click event happens before the after select event which will then fire the
code for NodeB.

How can I solve this issue?


What's about the SelectedNode property on the tree?


Nov 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Ian Powell | last post: by
13 posts views Thread by André Nogueira | last post: by
6 posts views Thread by L.M | last post: by
14 posts views Thread by Mr.D | last post: by
1 post views Thread by Alex D. | last post: by
8 posts views Thread by Matt MacDonald | last post: by
18 posts views Thread by =?Utf-8?B?TGkgV2VuZw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.