TreeView node... | | |
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 | | | | re: TreeView node...
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:
[color=blue]
> 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
>
>
>[/color] | | | | re: TreeView node...
I apologize, I misread some of what you said before replying... Click doesn’t
always occur after BeforeSelect or AfterSelect.
Brendan
"Brendan Grant" wrote:
[color=blue]
> 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:
>[color=green]
> > 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
> >
> >
> >[/color][/color] | | | | re: TreeView node...
"Tim" <tim@home.com> wrote in message
news:hMP2f.4166$S43.405087@news20.bellglobal.com.. .[color=blue]
> 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?[/color]
What's about the SelectedNode property on the tree? | | | | re: TreeView node...
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:
[color=blue]
> "Tim" <tim@home.com> wrote in message
> news:hMP2f.4166$S43.405087@news20.bellglobal.com.. .[color=green]
> > 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?[/color]
>
> What's about the SelectedNode property on the tree?
>
>
>[/color] | | | | re: TreeView node...
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:[color=blue]
> 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:
>[color=green]
> > "Tim" <tim@home.com> wrote in message
> > news:hMP2f.4166$S43.405087@news20.bellglobal.com.. .[color=darkred]
> > > 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?[/color]
> >
> > What's about the SelectedNode property on the tree?
> >
> >
> >[/color][/color] | | | | re: TreeView node...
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:[color=blue]
> 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:
>[color=green]
> > "Tim" <tim@home.com> wrote in message
> > news:hMP2f.4166$S43.405087@news20.bellglobal.com.. .[color=darkred]
> > > 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?[/color]
> >
> > What's about the SelectedNode property on the tree?
> >
> >
> >[/color][/color] |  | Similar C# / C Sharp bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,533 network members.
|