Private Sub Command1_Click() Dim strSql As String Dim cn As New ADODB.Connection,rs As New ADODB.Recordset cn.Open ".....连接字符串" strSql="select 手机号 from 表 where 姓名='" & TreeView1.SelectedItem.Text & "'" rs.Open strSql,cn,1,1 If Not rs.EOF Then Text1.Text=rs(0) & "" rs.Close cn.Close Set rs=Nothing Set cn=Nothing End Sub
同步 Private Sub Form_Load() TreeView1.Checkboxes = True '同步 Private Sub CheckChild(ByVal Node As MSComctlLib.Node, ByVal bCheck As Boolean, Optional ByVal bNext As Boolean = True, Optional ByVal bChild As Boolean = True) If Not Node Is Nothing Then '同步 Node.Checked = bCheck If Node.Children And bChild Then Call CheckChild(Node.Child, bCheck, True, True) '对子节点 End If If bNext Then Call CheckChild(Node.Next, bCheck, True, bChild) '对同一层节点 End If End If End SubPrivate Sub TreeView1_NodeCheck(ByVal Node As MSComctlLib.Node) Call CheckChild(Node, Node.Checked, False, True) '同步
Dim strSql As String
Dim cn As New ADODB.Connection,rs As New ADODB.Recordset
cn.Open ".....连接字符串"
strSql="select 手机号 from 表 where 姓名='" & TreeView1.SelectedItem.Text & "'"
rs.Open strSql,cn,1,1
If Not rs.EOF Then Text1.Text=rs(0) & ""
rs.Close
cn.Close
Set rs=Nothing
Set cn=Nothing
End Sub
Private Sub Form_Load()
TreeView1.Checkboxes = True '同步
Private Sub CheckChild(ByVal Node As MSComctlLib.Node, ByVal bCheck As Boolean, Optional ByVal bNext As Boolean = True, Optional ByVal bChild As Boolean = True)
If Not Node Is Nothing Then '同步
Node.Checked = bCheck
If Node.Children And bChild Then
Call CheckChild(Node.Child, bCheck, True, True) '对子节点
End If
If bNext Then
Call CheckChild(Node.Next, bCheck, True, bChild) '对同一层节点
End If
End If
End SubPrivate Sub TreeView1_NodeCheck(ByVal Node As MSComctlLib.Node)
Call CheckChild(Node, Node.Checked, False, True) '同步