473,402 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

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 6700
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ian Powell | last post by:
Hi I've got objects in an sorted ArrayList like: P:\ P:\\DOCS P:\\i386 P:\\i386\ASMS P:\\i386\ASMS\1000 P:\\i386\ASMS\1000\MSFT
13
by: André Nogueira | last post by:
Hi there. I know you can view a node's fullpath property, but is it posible to select a node using its path? Like, tell the treeview that the node that should be selected is the node with the...
6
by: L.M | last post by:
Hello, I knew how to use the treeview under VB6. After migrating to .NET, well, I'm lost. I try to add a new node, either to the same level or as a child to a selected node in the treeview....
14
by: Mr.D | last post by:
How do I save/load the contents of a Treeview to a file? I have found several good examples written i VB6, but not a single one for VB.NET. Please help. ---- Tim
2
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView...
0
by: Treeview Trouble | last post by:
I have an application where there are two radio buttons each of which populates a treeview control with a directory structure. Each radio button corresponds to a different directory which may or...
1
by: Alex D. | last post by:
hey guys I found what is causing the problems with my treeview in Firefox...the answer is: treeview+dropdwonlist in the same page dont work! try this simple code and see for yourselves. you can do...
8
by: Matt MacDonald | last post by:
Hi All, I have a form that displays hierarchical categories in a treeview. Ok so far so good. What I was to do is have users be able to select a node in the treeview as part of filling out the...
0
by: jiing | last post by:
Hi all, I want to use sting(the same as Node.Text) to judge if a node exists in TreeView. I've tried several ways, but seems all failed. could anybody help me? Thanks in advance. //My...
18
by: =?Utf-8?B?TGkgV2VuZw==?= | last post by:
Hi, Is there a way for TreeView to have multiple selections? But I am not talking about its checked boxes. I want a way similar to ListView with MultiSelect = True. So I can use or key and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.