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.TreeNodeMouseClickEventArgs) 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.Name
'//Exit the program
Case "InboxNode"
End Select
End Sub
End Class
Thanks,
Adam 3 1259
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*******@Webmaster2001.freeserve.co.uk> schreef in bericht
news:%2******************@TK2MSFTNGP03.phx.gbl... 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.TreeNodeMouseClickEventArgs) 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.Name
'//Exit the program
Case "InboxNode"
End Select
End Sub
End Class Thanks,
Adam
I would guess that the sender argument is actually the TreeView itself
Use e.Node to get the clicked node
/claes
"Adam Honek" <Ad*******@Webmaster2001.freeserve.co.uk> wrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl... 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.TreeNodeMouseClickEventArgs) 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.Name
'//Exit the program
Case "InboxNode"
End Select
End Sub
End Class Thanks,
Adam
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**************@TK2MSFTNGP03.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*******@Webmaster2001.freeserve.co.uk> wrote in message news:%2******************@TK2MSFTNGP03.phx.gbl... 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.TreeNodeMouseClickEventArgs) 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.Name
'//Exit the program
Case "InboxNode"
End Select
End Sub
End Class Thanks,
Adam
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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.)
...
|
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...
|
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 ...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
| |