473,769 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tree view node selection error

Hi,

I have the code below that I'm using in a tree view to detect what node the
user has clicked on.

It compiles but on runtime I get a type cast error.

I've used this method for both the tool bar and menu and it works fine
extending the "handles" property inherent within .net.

Isn't the type supposed to be "TreeNode"?

Private Sub tvSelectFolder_ NodeMouseClick( ByVal sender As Object, ByVal e As
System.Windows. Forms.TreeNodeM ouseClickEventA rgs) Handles
tvSelectFolder. NodeMouseClick

'Declare an object of type TreeNode

Dim pTreeViewNode As TreeNode

'Now let's find out which tree view node was clicked

pTreeViewNode = CType(sender, TreeNode)

'Each item corresponds to a different feature

Select Case pTreeViewNode.N ame

'//Exit the program

Case "InboxNode"

End Select

End Sub

End Class

Thanks,

Adam
Apr 10 '06 #1
3 1268
Adam,

Did you set (as would be done as first if you have a casting problem) set in
top of your program or in the options: Option Strict On

That helps mostly to find casting errors.

Cor

"Adam Honek" <Ad*******@Webm aster2001.frees erve.co.uk> schreef in bericht
news:%2******** **********@TK2M SFTNGP03.phx.gb l...
Hi,

I have the code below that I'm using in a tree view to detect what node
the user has clicked on.

It compiles but on runtime I get a type cast error.

I've used this method for both the tool bar and menu and it works fine
extending the "handles" property inherent within .net.

Isn't the type supposed to be "TreeNode"?

Private Sub tvSelectFolder_ NodeMouseClick( ByVal sender As Object, ByVal e
As System.Windows. Forms.TreeNodeM ouseClickEventA rgs) Handles
tvSelectFolder. NodeMouseClick

'Declare an object of type TreeNode

Dim pTreeViewNode As TreeNode

'Now let's find out which tree view node was clicked

pTreeViewNode = CType(sender, TreeNode)

'Each item corresponds to a different feature

Select Case pTreeViewNode.N ame

'//Exit the program

Case "InboxNode"

End Select

End Sub

End Class

Thanks,

Adam

Apr 11 '06 #2
I would guess that the sender argument is actually the TreeView itself
Use e.Node to get the clicked node

/claes

"Adam Honek" <Ad*******@Webm aster2001.frees erve.co.uk> wrote in message
news:%2******** **********@TK2M SFTNGP03.phx.gb l...
Hi,

I have the code below that I'm using in a tree view to detect what node
the user has clicked on.

It compiles but on runtime I get a type cast error.

I've used this method for both the tool bar and menu and it works fine
extending the "handles" property inherent within .net.

Isn't the type supposed to be "TreeNode"?

Private Sub tvSelectFolder_ NodeMouseClick( ByVal sender As Object, ByVal e
As System.Windows. Forms.TreeNodeM ouseClickEventA rgs) Handles
tvSelectFolder. NodeMouseClick

'Declare an object of type TreeNode

Dim pTreeViewNode As TreeNode

'Now let's find out which tree view node was clicked

pTreeViewNode = CType(sender, TreeNode)

'Each item corresponds to a different feature

Select Case pTreeViewNode.N ame

'//Exit the program

Case "InboxNode"

End Select

End Sub

End Class

Thanks,

Adam

Apr 11 '06 #3
Thanks, this does the trick using the "e" argument.

BTW, Option Strict was off.

Adam

"Claes Bergefall" <lo*****@nospam .nospam> wrote in message
news:OD******** ******@TK2MSFTN GP03.phx.gbl...
I would guess that the sender argument is actually the TreeView itself
Use e.Node to get the clicked node

/claes

"Adam Honek" <Ad*******@Webm aster2001.frees erve.co.uk> wrote in message
news:%2******** **********@TK2M SFTNGP03.phx.gb l...
Hi,

I have the code below that I'm using in a tree view to detect what node
the user has clicked on.

It compiles but on runtime I get a type cast error.

I've used this method for both the tool bar and menu and it works fine
extending the "handles" property inherent within .net.

Isn't the type supposed to be "TreeNode"?

Private Sub tvSelectFolder_ NodeMouseClick( ByVal sender As Object, ByVal e
As System.Windows. Forms.TreeNodeM ouseClickEventA rgs) Handles
tvSelectFolder. NodeMouseClick

'Declare an object of type TreeNode

Dim pTreeViewNode As TreeNode

'Now let's find out which tree view node was clicked

pTreeViewNode = CType(sender, TreeNode)

'Each item corresponds to a different feature

Select Case pTreeViewNode.N ame

'//Exit the program

Case "InboxNode"

End Select

End Sub

End Class

Thanks,

Adam


Apr 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
14035
by: Steve Johnson | last post by:
Been banging my head on this for two days now. Hope someone can help! My test program below is in the form of a single JSP, with a Node class build in. (All the coded needed to run is below.) The technical requirements: 1) Store tree data in the database so that it can be extracted as a tree structure. For test purposes,
0
2180
by: Tree menu using XML | last post by:
I have one XML file that has nodes and sub node and each and every node has the attribute call visible if its value is true then diplay this node else don't display thid node, but this condition i am able to check using xpath in asp.net 2.0 till MenuItem node. if i check visible attribute value till SubMenuLevel0 node then in tree it will not display the MenuItem Node at all Note: My tree Menu will start from MenuItem node and it will...
4
4821
by: ghanley | last post by:
Hi Guys, I need some help with a problem related to the looping through a recordset to display on a tree view control. My table has no Primary key - because duplicates are allowed. ID parent 1 2 1
3
6060
by: Saradhi | last post by:
Hi All, Here I am facing a performance problem with the TreeView Node renaming. I am displaying a hierarchy Data in a treeview in my Windows C# Application. My tree view represents an hierarchical view of Parent Nodes and projects where in a projectnode can be added to any ParentNode and hence we may have a project node added to 100 Parent nodes. In this one, I have an operation of Renaming a Project Node. So whenever I am doing the...
1
3062
by: JN | last post by:
Hi All, I have a tree view which has parent nodes of each letter of the alphabet. The root node will be the customers name that relate to the parent node letter. I also have a gridview which is binded to the treeview control to display all customer records of the selected alphabetical letter. When I click expand the tree view and click on the customer's name, I get this error.: Please bear in mind that I have only been using ASP.net...
2
13138
by: Jerry Langley | last post by:
Once a treeview node is selected how can I programmatically unselect it so that it might be selected again following the first selection if the user desires? The after selection event only fires when the selection changes.
2
1351
by: dave.dolan | last post by:
I have generated a nice tree view that displays some otherwise cyptic XML in an easy to follow manner. The trouble is that the TreeView assumes that I'm wanting a link in each of the nodes, and I really just want to display them for view only. How can I disable the link-ness of the data in the tree view? I have tried setting the target of the links to "javascript:false;" but it still causes a postback and flashes the page to the top...
7
1468
by: Adam Honek | last post by:
Hi all, How do we select a tree view's node outside of a tree view event? Looking through the lists there's no select function, the nearest I can find is GetNodeAt but this seems to want the screen coordinates. Thanks, Adam
0
1140
by: Rohit111111 | last post by:
Hello all, I have a tree view control that will populate data upto n level,on selection of a node i am binding a datagrid on the same page,now i have to expand that node which i have selected,which is not expanded currently,after selecting a node data grid will be bind correctly but my tree will collasp all node i have to exapnd only that node which i have selected please help
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10215
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9996
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3964
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3564
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.