问题描述
'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
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我正在使用树视图我收到错误
指定的参数超出了有效值的范围。参数名称:索引
如何清除此
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
推荐答案
If TreeView1.Nodes(1).IsSelected = True Then
此行出错
然后很明显:无论出于何种原因,您的Treeview不包含至少两个节点。
如果没有代码所在的上下文,并且包含要加载到TreeView中的数据,为什么很难说。所以...问题必须由你来解决!
在引发错误的行上设置断点,并在断点处停止,直接在调试器中查看Nodes集合。你有几个节点?你应该有多少?代码是什么方法?什么时候被召唤?从哪里来?
看那个地段应该给你一个想法 - 如果不是解决方案本身,它应该给你更好的信息来解决问题,或告诉你我们会更准确地说明导致错误的原因。
对不起,但如果没有更好的信息,这几乎是我们能做的最好的事情!
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!
这篇关于参数超出范围异常参数名称:index的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!