如何把下列代码改成修改treeview 控件节点
Private Sub mnuTmlb_Click()Dim frm As New frmTmlb
Dim rs As ADODB.Recordset
Dim MaxID As Integer
Dim szSQL As String
On Error GoTo ErrHandler
frm.Show vbModal
If frm.IsCancelled = True Then
Exit Sub
End If
'--------------------------------------
Set rs = gadoCONN.Execute("SELECT Max(id) as MaxID FROM tbTmlb")
If Not rs.EOF Then rs.MoveLast
If Not rs.BOF Then rs.MoveFirst
If rs.RecordCount >= 1 Then
MaxID = ToInteger(rs("MaxID")) + 1
Else
MaxID = 1
End If
Set rs = Nothing
szSQL = "INSERT INTO tbTmlb(id,name) VALUES(" & CStr(MaxID) & ",'" & frm.TmlbMC & "')"
'添加到数据中
gadoCONN.Execute szSQL
'添加到树形控件中
Call AddTmlbNode(MaxID, frm.TmlbMC)
Exit Sub
ErrHandler:
Set rs = Nothing
ErrMessageBox "添加题目类别mnuTmlb_Click()", "提示"
End Sub
'添加题目类别到题库树上
Private Sub AddTmlbNode(ByVal Tmlb_id As Integer, ByVal tmmc As String)
Dim Nodex As Node
'添加到树形控件中
Set Nodex = TreeView1.Nodes(1) '树根
Set Nodex = TreeView1.Nodes.Add(CStr(Nodex.Key), tvwChild, "TMLB_" & CStr(Tmlb_id), tmmc, 2, 2)
Nodex.Tag = CStr(Tmlb_id)
Set Nodex = TreeView1.Nodes.Add("TMLB_" & CStr(Tmlb_id), tvwChild, "TMLB_" & CStr(Tmlb_id) & "_0", "选择题", 3, 3)
Nodex.Tag = "0"
Set Nodex = TreeView1.Nodes.Add("TMLB_" & CStr(Tmlb_id), tvwChild, "TMLB_" & CStr(Tmlb_id) & "_1", "判断题", 3, 3)
Nodex.Tag = "1"
End Sub