Click here to Skip to main content
15,072,433 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
'Employee Information main tree view
      If TreeView1.Nodes(1).IsSelected = True Then
          TabControl1.SelectedTabPage = TabPage1
          TreeView1.Nodes(1).ExpandAll()
          flag = 1
          GoTo s
          Exit Sub
      End If


VB
If TreeView1.Nodes(1).Nodes(0).IsSelected = True Then
           If HRManagement.uname = "fot" Or HRManagement.uname = "FOT" Then
               TabControl1.SelectedTabPage = EmployeeinformationTabPage
               empinfoload()
               flag = 1
               GoTo s
               Exit Sub
           Else
               Dim i As Integer = HRManagement.report.Length()
               Do
                   i = i - 1
                   If HRManagement.report(i) = "Emp Employee Information" Then
                       TabControl1.SelectedTabPage = EmployeeinformationTabPage
                       empinfoload()
                       con1.Open()
                       cmd.CommandText = "select * from usersecurity where groupname='" & Trim(HRManagement.gname) & "' and caption='" & "Emp Employee Information" & "'"
                       cmd.Connection = con1
                       reader = cmd.ExecuteReader()
                       reader.Read()
                       If Val(reader(4)) = 0 Then
                           EISaveToolStripMenuItem.Enabled = False
                       End If
                       If Val(reader(5)) = 0 Then
                           EIFindToolStripMenuItem.Enabled = False
                       End If
                       If Val(reader(6)) = 0 Then
                           EIUpdateToolStripMenuItem.Enabled = False
                       End If
                       If Val(reader(7)) = 0 Then
                           EIDeleteToolStripMenuItem.Enabled = False
                       End If
                       con1.Close()
                       flag = 1
                       GoTo s
                       Exit Sub
                   End If
               Loop Until i <= 0
           End If
       End If






i am using tree view i got an error as

Specified argument was out of the range of valid values.Parameter name: index

how can i clear this
Posted
Updated 5-Jan-14 22:00pm
v2
Comments
OriginalGriff 6-Jan-14 4:01am
   
Where?
Which line gives the error?
shakeer mp 6-Jan-14 5:08am
   
If TreeView1.Nodes(1).IsSelected = True Then
this line got error
Kornfeld Eliyahu Peter 6-Jan-14 5:32am
   
Obviously you have no nodes in the tree!

1 solution

VB
If TreeView1.Nodes(1).IsSelected = True Then

this line got error

Then it's pretty obvious: for whatever reason, your Treeview does not contain at least two nodes.

Exactly why is difficult to say without the context in which that code sits, and that includes the data you are loading into your TreeView. So...the problem is going to have to be solved by you!

Put a breakpoint on the line that throws the error, and when it stops at the breakpoint, look at the Nodes collection directly in the debugger. How many nodes have you got? How many should you have? What method is the code in? When did it get called? From where?

Looking at that lot should give you an idea - if not the solution itself, it should give you better information to either work out the solution, or tell us more accurately what happens to cause the error.

Sorry, but that's pretty much the best we can do without better info!
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900