Treeview, SelectedIndexChange, responding to a click event - LT 
Author Message
 Treeview, SelectedIndexChange, responding to a click event - LT
I am desperatly trying to figure out how to get a treeview to respond to a
click event. I have Zero problems filling the tree (actually I am using XML
and SQL) but need to get the last bracnh of the tree which is a number fill
in a form. i.e. i click on the last bracnh which is a number 382 and then it
runs a stored proc which returns a result set based on that number which
then fills a form

select * from viewname where id = '382'.

Regardless i can't get the treeview to respond to a simple click. Here is
the best example code that i have. A few things first

What is the difference between
OnSelectedIndexChange and
SelectedIndexChange  goto the ms site SelectedIndexChange is listed as an
event of the treeview control and when you click on it, it takes you to a
page with a head of
OnSelectedIndexChange

Anyways I have tried both to no avail. If anyone can give me a simple
example of how to get the treeview to respond to a click event i would
REALLY appreicate it.
Note: I have tried many things in the dothischange sub, filling a textbox
etc it seems as if it is purely  not responding to a click.
Note: There is a bug that the treeview will not render through the IDE if
you run your app in debug (f5) so it is hard as hell to troubleshoot this as
breakpoints etc don't do diddly since you have to run with no debug to get
the tree to render.

Help is greatly greatly appreciated,

James Morton



assembly="microsoft.web.ui.webcontrols"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en">
<html>
<head>
  <title></title>
  <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
  <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
  <meta name="vs_defaultClientScript" content="javascript">
  <meta name="vs_targetSchema"
content=" http://www.*-*-*.com/ ;>
  <script language="vb" runat="server">

   Private Sub TreeView1_SelectedIndexChange(ByVal sender As Object, ByVal e
As Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs)
    Label1.text= e.OldNode
    Label2.text= e.NewNode
   End Sub
  </script>
</head>
<body ms_positioning="gridlayout">
  <form id="Form1" method="post" runat="server">
   <mytree:treeview id="Treeview1" runat="server" autopostback="true"
 SelectedIndexChange="TreeView1_SelectedIndexChange">
    <mytree:treenode text="node1">
     <mytree:treenode text="node2">
     </mytree:treenode>
    </mytree:treenode>
    <mytree:treenode text="node3">
    </mytree:treenode>
   </mytree:treeview>
   <br>
   <asp:Label ID="Label1" text= "label1" runat="server"></asp:Label>
   <br>
   <asp:Label ID="Label2" runat="server"></asp:Label>
  </form>
</body>
</html>



Sun, 28 Mar 2004 00:25:07 GMT  
 Treeview, SelectedIndexChange, responding to a click event - LT
Hi,

I use the TreeView_AfterSelect event and it seems to be working fine.  Use a
case statement to find out which node is selected and then take the
appropriate action.  I use the TreeNode.Tag property to uniquely identify
each node.  Then in the _AfterSelect event I can use e.Node.Tag to find out
which node was clicked.  Hope this helps.

Javed Aslam


Quote:
> I am desperatly trying to figure out how to get a treeview to respond to a
> click event. I have Zero problems filling the tree (actually I am using
XML
> and SQL) but need to get the last bracnh of the tree which is a number
fill
> in a form. i.e. i click on the last bracnh which is a number 382 and then
it
> runs a stored proc which returns a result set based on that number which
> then fills a form

> select * from viewname where id = '382'.

> Regardless i can't get the treeview to respond to a simple click. Here is
> the best example code that i have. A few things first

> What is the difference between
> OnSelectedIndexChange and
> SelectedIndexChange  goto the ms site SelectedIndexChange is listed as an
> event of the treeview control and when you click on it, it takes you to a
> page with a head of
> OnSelectedIndexChange

> Anyways I have tried both to no avail. If anyone can give me a simple
> example of how to get the treeview to respond to a click event i would
> REALLY appreicate it.
> Note: I have tried many things in the dothischange sub, filling a textbox
> etc it seems as if it is purely  not responding to a click.
> Note: There is a bug that the treeview will not render through the IDE if
> you run your app in debug (f5) so it is hard as hell to troubleshoot this
as
> breakpoints etc don't do diddly since you have to run with no debug to get
> the tree to render.

> Help is greatly greatly appreciated,

> James Morton



> assembly="microsoft.web.ui.webcontrols"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en">
> <html>
> <head>
>   <title></title>
>   <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
>   <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
>   <meta name="vs_defaultClientScript" content="javascript">
>   <meta name="vs_targetSchema"
> content="http://schemas.microsoft.com/intellisense/ie5">
>   <script language="vb" runat="server">

>    Private Sub TreeView1_SelectedIndexChange(ByVal sender As Object, ByVal
e
> As Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs)
>     Label1.text= e.OldNode
>     Label2.text= e.NewNode
>    End Sub
>   </script>
> </head>
> <body ms_positioning="gridlayout">
>   <form id="Form1" method="post" runat="server">
>    <mytree:treeview id="Treeview1" runat="server" autopostback="true"
>  SelectedIndexChange="TreeView1_SelectedIndexChange">
>     <mytree:treenode text="node1">
>      <mytree:treenode text="node2">
>      </mytree:treenode>
>     </mytree:treenode>
>     <mytree:treenode text="node3">
>     </mytree:treenode>
>    </mytree:treeview>
>    <br>
>    <asp:Label ID="Label1" text= "label1" runat="server"></asp:Label>
>    <br>
>    <asp:Label ID="Label2" runat="server"></asp:Label>
>   </form>
> </body>
> </html>



Sun, 28 Mar 2004 03:35:47 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Respond to click on treeview

2. Why Click Event if VB won't respond

3. <<Program>> Not Responding

4. <<<<<<<PROGRAMA GRATUITO PARA WINDOWS 95 /NT<<<<<<<<<<<

5. one SQL datacontrol or many TABLE datacontrols<<<<<<<<<<<<<<<<<

6. *************** TRADING TRANSCENDER <<<<<<<<<<<<<<<<

7. No node click event in Windows.Forms.TreeView?

8. TreeView -Click Event on Plus Sign Node

9. --treeview click event ???

10. TreeView Not firing click event

11. Treeview: highlight node with control Click event

12. Treeview node Click event?

 

 
Powered by phpBB® Forum Software