Tree Control Problem

G

Guest

I am having a problem the first time I click on a node. In the below code, I
am catching the error "object reference not set to an instance of an object".

This is only on the deployed app. I don't get this when I run in the IDE.

Private SelectedNode As TreeNode

Private Sub treeBuiltRoutes_AfterSelect(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles
treeBuiltRoutes.AfterSelect

If e.Node.Parent Is Nothing Then
Dim x As Integer
Try
x = SelectedNode.Index
Catch ex As Exception
MsgBox(ex.Message)
End Try
 
R

Ronchese

Where come from the SelectedNode object? I can't see where it's referenced.

Anyways, try to check if the e.Node object is nothing, before continue your
procedure.

[]s
Cesar



"EdB" <[email protected]> escreveu na mensagem
I am having a problem the first time I click on a node. In the below code,
I
am catching the error "object reference not set to an instance of an
object".

This is only on the deployed app. I don't get this when I run in the IDE.

Private SelectedNode As TreeNode

Private Sub treeBuiltRoutes_AfterSelect(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles
treeBuiltRoutes.AfterSelect

If e.Node.Parent Is Nothing Then
Dim x As Integer
Try
x = SelectedNode.Index
Catch ex As Exception
MsgBox(ex.Message)
End Try
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top