No node click event in Windows.Forms.TreeView?
Author |
Message |
Lifen #1 / 8
|
 No node click event in Windows.Forms.TreeView?
I am customizing Windows.Forms.TreeView to add functionalities. It seems however, that TreeView class doesn't have a "node clicked" type of event. The only thing close to it is the AfterSelect event. But it doesn't realy meet our needs. I find it hard to believe that such an important event is missing from the control. But I just can't find it. Am I missing somthing here? (By the way I am not inheriting AxMSComctlLib.AxTreeView, although it does have the node_clicked event, because it gives me strange errors like "ActiveX state error..." when I use it, and I can't figure out why) Please help. Lifeng
|
Thu, 01 Sep 2005 04:02:14 GMT |
|
 |
Richard T. Edarard #2 / 8
|
 No node click event in Windows.Forms.TreeView?
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect End Sub Private Sub TreeView1_BeforeSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles TreeView1.BeforeSelect End Sub Before select tells you where you were After select tells you what is currently selected.
Quote: > I am customizing Windows.Forms.TreeView to add > functionalities. It seems however, that TreeView class > doesn't have a "node clicked" type of event. The only > thing close to it is the AfterSelect event. But it doesn't > realy meet our needs. I find it hard to believe that such > an important event is missing from the control. But I just > can't find it. > Am I missing somthing here? > (By the way I am not inheriting AxMSComctlLib.AxTreeView, > although it does have the node_clicked event, because it > gives me strange errors like "ActiveX state error..." when > I use it, and I can't figure out why) > Please help. > Lifeng
|
Thu, 01 Sep 2005 06:34:08 GMT |
|
 |
Lifen #3 / 8
|
 No node click event in Windows.Forms.TreeView?
Thanks for you reply. Neither will work in the follwing scenario: A MDI container contains 2 panles, one with a treeview in it, the other displays different forms according to tree nodes you select. When you select a node from the tree, a form will open. Leave the node still selected while close the form in the other panle. Now(the node is still selected by the form is closed), if you want to open the same form by clicking on the already selected node, guess what, it won't work -- you have to click somewhere else and click back again. That's the difference between node_click event and those "before" or "after"s. Any idea? Thanks Quote: >-----Original Message----- >Private Sub TreeView1_AfterSelect(ByVal sender As
System.Object, ByVal e As Quote: >System.Windows.Forms.TreeViewEventArgs) Handles
TreeView1.AfterSelect Quote: >End Sub >Private Sub TreeView1_BeforeSelect(ByVal sender As Object, ByVal e As >System.Windows.Forms.TreeViewCancelEventArgs) Handles
TreeView1.BeforeSelect Quote: >End Sub >Before select tells you where you were >After select tells you what is currently selected.
>> I am customizing Windows.Forms.TreeView to add >> functionalities. It seems however, that TreeView class >> doesn't have a "node clicked" type of event. The only >> thing close to it is the AfterSelect event. But it doesn't >> realy meet our needs. I find it hard to believe that such >> an important event is missing from the control. But I just >> can't find it. >> Am I missing somthing here? >> (By the way I am not inheriting
AxMSComctlLib.AxTreeView, Quote: >> although it does have the node_clicked event, because it >> gives me strange errors like "ActiveX state error..." when >> I use it, and I can't figure out why) >> Please help. >> Lifeng >.
|
Thu, 01 Sep 2005 08:19:37 GMT |
|
 |
Stephen Marti #4 / 8
|
 No node click event in Windows.Forms.TreeView?
Use the Click event of the TreeView. To find what node was clicked, if any, use the MousePosition property and GetNodeAt method.
Quote: > Thanks for you reply. > Neither will work in the follwing scenario: > A MDI container contains 2 panles, one with a treeview in > it, the other displays different forms according to tree > nodes you select. When you select a node from the tree, a > form will open. Leave the node still selected while close > the form in the other panle. Now(the node is still > selected by the form is closed), if you want to open the > same form by clicking on the already selected node, guess > what, it won't work -- you have to click somewhere else > and click back again. > That's the difference between node_click event and > those "before" or "after"s. > Any idea? > Thanks > >-----Original Message----- > >Private Sub TreeView1_AfterSelect(ByVal sender As > System.Object, ByVal e As > >System.Windows.Forms.TreeViewEventArgs) Handles > TreeView1.AfterSelect > >End Sub > >Private Sub TreeView1_BeforeSelect(ByVal sender As > Object, ByVal e As > >System.Windows.Forms.TreeViewCancelEventArgs) Handles > TreeView1.BeforeSelect > >End Sub > >Before select tells you where you were > >After select tells you what is currently selected.
> >> I am customizing Windows.Forms.TreeView to add > >> functionalities. It seems however, that TreeView class > >> doesn't have a "node clicked" type of event. The only > >> thing close to it is the AfterSelect event. But it > doesn't > >> realy meet our needs. I find it hard to believe that > such > >> an important event is missing from the control. But I > just > >> can't find it. > >> Am I missing somthing here? > >> (By the way I am not inheriting > AxMSComctlLib.AxTreeView, > >> although it does have the node_clicked event, because it > >> gives me strange errors like "ActiveX state error..." > when > >> I use it, and I can't figure out why) > >> Please help. > >> Lifeng > >.
|
Thu, 01 Sep 2005 08:22:54 GMT |
|
 |
Lifen #5 / 8
|
 No node click event in Windows.Forms.TreeView?
Thank you for your reply. But could you be more specific? How do you use the MousePosition property and GetNodeAt method? the TreeViewEventArgs only gives you 2 property/method: Empty and GetType. Quote: >-----Original Message----- >Use the Click event of the TreeView. To find what node
was clicked, if any, Quote: >use the MousePosition property and GetNodeAt method.
>> Thanks for you reply. >> Neither will work in the follwing scenario: >> A MDI container contains 2 panles, one with a treeview in >> it, the other displays different forms according to tree >> nodes you select. When you select a node from the tree, a >> form will open. Leave the node still selected while close >> the form in the other panle. Now(the node is still >> selected by the form is closed), if you want to open the >> same form by clicking on the already selected node, guess >> what, it won't work -- you have to click somewhere else >> and click back again. >> That's the difference between node_click event and >> those "before" or "after"s. >> Any idea? >> Thanks >> >-----Original Message----- >> >Private Sub TreeView1_AfterSelect(ByVal sender As >> System.Object, ByVal e As >> >System.Windows.Forms.TreeViewEventArgs) Handles >> TreeView1.AfterSelect >> >End Sub >> >Private Sub TreeView1_BeforeSelect(ByVal sender As >> Object, ByVal e As >> >System.Windows.Forms.TreeViewCancelEventArgs) Handles >> TreeView1.BeforeSelect >> >End Sub >> >Before select tells you where you were >> >After select tells you what is currently selected.
>> >> I am customizing Windows.Forms.TreeView to add >> >> functionalities. It seems however, that TreeView class >> >> doesn't have a "node clicked" type of event. The only >> >> thing close to it is the AfterSelect event. But it >> doesn't >> >> realy meet our needs. I find it hard to believe that >> such >> >> an important event is missing from the control. But I >> just >> >> can't find it. >> >> Am I missing somthing here? >> >> (By the way I am not inheriting >> AxMSComctlLib.AxTreeView, >> >> although it does have the node_clicked event, because it >> >> gives me strange errors like "ActiveX state error..." >> when >> >> I use it, and I can't figure out why) >> >> Please help. >> >> Lifeng >> >. >.
|
Thu, 01 Sep 2005 09:53:07 GMT |
|
 |
Lifen #6 / 8
|
 No node click event in Windows.Forms.TreeView?
I guess I know how to call the method now, but it still behave strangely. The line: Dim oNod As {*filter*}ode = GetNodeAt(MousePosition) Always gives me a node that's 3 positions bellow the one clicked on. How's that? Quote: >-----Original Message----- >Use the Click event of the TreeView. To find what node
was clicked, if any, Quote: >use the MousePosition property and GetNodeAt method.
>> Thanks for you reply. >> Neither will work in the follwing scenario: >> A MDI container contains 2 panles, one with a treeview in >> it, the other displays different forms according to tree >> nodes you select. When you select a node from the tree, a >> form will open. Leave the node still selected while close >> the form in the other panle. Now(the node is still >> selected by the form is closed), if you want to open the >> same form by clicking on the already selected node, guess >> what, it won't work -- you have to click somewhere else >> and click back again. >> That's the difference between node_click event and >> those "before" or "after"s. >> Any idea? >> Thanks >> >-----Original Message----- >> >Private Sub TreeView1_AfterSelect(ByVal sender As >> System.Object, ByVal e As >> >System.Windows.Forms.TreeViewEventArgs) Handles >> TreeView1.AfterSelect >> >End Sub >> >Private Sub TreeView1_BeforeSelect(ByVal sender As >> Object, ByVal e As >> >System.Windows.Forms.TreeViewCancelEventArgs) Handles >> TreeView1.BeforeSelect >> >End Sub >> >Before select tells you where you were >> >After select tells you what is currently selected.
>> >> I am customizing Windows.Forms.TreeView to add >> >> functionalities. It seems however, that TreeView class >> >> doesn't have a "node clicked" type of event. The only >> >> thing close to it is the AfterSelect event. But it >> doesn't >> >> realy meet our needs. I find it hard to believe that >> such >> >> an important event is missing from the control. But I >> just >> >> can't find it. >> >> Am I missing somthing here? >> >> (By the way I am not inheriting >> AxMSComctlLib.AxTreeView, >> >> although it does have the node_clicked event, because it >> >> gives me strange errors like "ActiveX state error..." >> when >> >> I use it, and I can't figure out why) >> >> Please help. >> >> Lifeng >> >. >.
|
Thu, 01 Sep 2005 10:23:46 GMT |
|
 |
Stephen Marti #7 / 8
|
 No node click event in Windows.Forms.TreeView?
MousePosition gives you the mouse coordinates in terms of the Screen. Use PointToClient to convert it to position relative to your control.
Quote: > I guess I know how to call the method now, but it still > behave strangely. The line: > Dim oNod As {*filter*}ode = GetNodeAt(MousePosition) > Always gives me a node that's 3 positions bellow the one > clicked on. How's that? > >-----Original Message----- > >Use the Click event of the TreeView. To find what node > was clicked, if any, > >use the MousePosition property and GetNodeAt method.
> >> Thanks for you reply. > >> Neither will work in the follwing scenario: > >> A MDI container contains 2 panles, one with a treeview > in > >> it, the other displays different forms according to tree > >> nodes you select. When you select a node from the tree, > a > >> form will open. Leave the node still selected while > close > >> the form in the other panle. Now(the node is still > >> selected by the form is closed), if you want to open the > >> same form by clicking on the already selected node, > guess > >> what, it won't work -- you have to click somewhere else > >> and click back again. > >> That's the difference between node_click event and > >> those "before" or "after"s. > >> Any idea? > >> Thanks > >> >-----Original Message----- > >> >Private Sub TreeView1_AfterSelect(ByVal sender As > >> System.Object, ByVal e As > >> >System.Windows.Forms.TreeViewEventArgs) Handles > >> TreeView1.AfterSelect > >> >End Sub > >> >Private Sub TreeView1_BeforeSelect(ByVal sender As > >> Object, ByVal e As > >> >System.Windows.Forms.TreeViewCancelEventArgs) Handles > >> TreeView1.BeforeSelect > >> >End Sub > >> >Before select tells you where you were > >> >After select tells you what is currently selected.
> >> >> I am customizing Windows.Forms.TreeView to add > >> >> functionalities. It seems however, that TreeView > class > >> >> doesn't have a "node clicked" type of event. The only > >> >> thing close to it is the AfterSelect event. But it > >> doesn't > >> >> realy meet our needs. I find it hard to believe that > >> such > >> >> an important event is missing from the control. But I > >> just > >> >> can't find it. > >> >> Am I missing somthing here? > >> >> (By the way I am not inheriting > >> AxMSComctlLib.AxTreeView, > >> >> although it does have the node_clicked event, > because it > >> >> gives me strange errors like "ActiveX state error..." > >> when > >> >> I use it, and I can't figure out why) > >> >> Please help. > >> >> Lifeng > >> >. > >.
|
Thu, 01 Sep 2005 20:04:38 GMT |
|
 |
Lifen #8 / 8
|
 No node click event in Windows.Forms.TreeView?
Thank you so much for your help Martin! That's exactly what I wanted. You'r such a genius! :) Honestly, I really appreciate it! Lifeng Quote: >-----Original Message----- >MousePosition gives you the mouse coordinates in terms of the Screen. Use >PointToClient to convert it to position relative to your control.
>> I guess I know how to call the method now, but it still >> behave strangely. The line: >> Dim oNod As {*filter*}ode = GetNodeAt(MousePosition) >> Always gives me a node that's 3 positions bellow the one >> clicked on. How's that? >> >-----Original Message----- >> >Use the Click event of the TreeView. To find what node >> was clicked, if any, >> >use the MousePosition property and GetNodeAt method.
>> >> Thanks for you reply. >> >> Neither will work in the follwing scenario: >> >> A MDI container contains 2 panles, one with a treeview >> in >> >> it, the other displays different forms according to tree >> >> nodes you select. When you select a node from the tree, >> a >> >> form will open. Leave the node still selected while >> close >> >> the form in the other panle. Now(the node is still >> >> selected by the form is closed), if you want to open the >> >> same form by clicking on the already selected node, >> guess >> >> what, it won't work -- you have to click somewhere else >> >> and click back again. >> >> That's the difference between node_click event and >> >> those "before" or "after"s. >> >> Any idea? >> >> Thanks >> >> >-----Original Message----- >> >> >Private Sub TreeView1_AfterSelect(ByVal sender As >> >> System.Object, ByVal e As >> >> >System.Windows.Forms.TreeViewEventArgs) Handles >> >> TreeView1.AfterSelect >> >> >End Sub >> >> >Private Sub TreeView1_BeforeSelect(ByVal sender As >> >> Object, ByVal e As >> >> >System.Windows.Forms.TreeViewCancelEventArgs) Handles >> >> TreeView1.BeforeSelect >> >> >End Sub >> >> >Before select tells you where you were >> >> >After select tells you what is currently selected.
>> >> >> I am customizing Windows.Forms.TreeView to add >> >> >> functionalities. It seems however, that TreeView >> class >> >> >> doesn't have a "node clicked" type of event. The only >> >> >> thing close to it is the AfterSelect event. But it >> >> doesn't >> >> >> realy meet our needs. I find it hard to believe that >> >> such >> >> >> an important event is missing from the control. But I >> >> just >> >> >> can't find it. >> >> >> Am I missing somthing here? >> >> >> (By the way I am not inheriting >> >> AxMSComctlLib.AxTreeView, >> >> >> although it does have the node_clicked event, >> because it >> >> >> gives me strange errors like "ActiveX state error..." >> >> when >> >> >> I use it, and I can't figure out why) >> >> >> Please help. >> >> >> Lifeng >> >> >. >> >. >.
|
Fri, 02 Sep 2005 02:57:06 GMT |
|
|
|