vb6.0,TreeView1中的无效的关键字。错误代码35603
PrivateSubForm_Load()SetNode1=TreeView1.Nodes.Add(,,"jsgy","工艺1")SetNode1=TreeView1.N...
Private Sub Form_Load()
Set Node1 = TreeView1.Nodes.Add(, , "jsgy", "工艺1")
Set Node1 = TreeView1.Nodes.Add(, , "gggy", "工艺2")
Dim Key, Text As String
Dim Nod As Node
Adodc1.Visible = False
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from 综合工艺 " '查询主节点
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveFirst
Do While Adodc1.Recordset.EOF = False
Key = Trim(Adodc1.Recordset.Fields("名称")) '主节点在treeview中显示
Text = Adodc1.Recordset.Fields("名称")
Set Node1 = TreeView1.Nodes.Add("jsgy", tvwChild, Key, Text) '!!!错误提示地方!!!
Adodc1.Recordset.MoveNext
Loop
End If
End Sub 展开
Set Node1 = TreeView1.Nodes.Add(, , "jsgy", "工艺1")
Set Node1 = TreeView1.Nodes.Add(, , "gggy", "工艺2")
Dim Key, Text As String
Dim Nod As Node
Adodc1.Visible = False
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from 综合工艺 " '查询主节点
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveFirst
Do While Adodc1.Recordset.EOF = False
Key = Trim(Adodc1.Recordset.Fields("名称")) '主节点在treeview中显示
Text = Adodc1.Recordset.Fields("名称")
Set Node1 = TreeView1.Nodes.Add("jsgy", tvwChild, Key, Text) '!!!错误提示地方!!!
Adodc1.Recordset.MoveNext
Loop
End If
End Sub 展开
展开全部
应该是你的表【 综合工艺】中的字段【"名称" 】内容有空白或者是重复的值。
将以下代码代替你原有的代码。
Private Sub Form_Load()
Set Node1 = TreeView1.Nodes.Add(, , "jsgy", "工艺1")
Set Node1 = TreeView1.Nodes.Add(, , "gggy", "工艺2")
Dim Key, Text As String
Dim I as Integer
Dim Nod As Node
Adodc1.Visible = False
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from 综合工艺 " '查询主节点
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveFirst
Do While Adodc1.Recordset.EOF = False
'Key = Trim(Adodc1.Recordset.Fields("名称")) '主节点在treeview中显示
I=I+1
Key ="K" & I & "-" & Trim(Adodc1.Recordset.Fields("名称"))
Text = Adodc1.Recordset.Fields("名称")
Set Node1 = TreeView1.Nodes.Add("jsgy", tvwChild, Key, Text) '!!!错误提示地方!!!
Adodc1.Recordset.MoveNext
Loop
End If
End Sub
追问
你好,我知道原因了,是key值有数字,不过你这样改也行。顺便问你下,点击节点
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
If TreeView1.selectedItem.Text = "精铣底面" Then
Text1.Text = "已修改"
End If
End Sub
怎么没反应啊, 哪里有问题啊?
追答
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
If Node.Text = "精铣底面" Then
Text1.Text = "已修改"
End If
End Sub
请参考上面的代码。
不过,如果你是想对treeview修改,然后判断是否被修改过,应该在afteredit的时间中处理。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询