VB Code:
  1. Dim strKEy As String
  2. Dim RemoteHost As String
  3.  
  4.  Private Sub Form_Load()
  5.     Dim x
  6.     Dim PCName As String
  7.     Dim Command As String
  8.     Dim Msg As String
  9.     Dim i As Integer
  10.  
  11.  ' Declarations
  12.     Dim intIDX As Integer
  13.    
  14.     ' Get List of Computers on Network (Type All: Server and Workstation)
  15.     ServerList = EnumServer(SRV_TYPE_ALL)
  16.    
  17.      ' Loop through all the computers and add them to the treeview
  18.     If ServerList.Init Then
  19.    
  20.         Dim rt As Node
  21.         Dim ch As Node
  22.         Dim strServer As String
  23.         Dim t
  24.         Set rt = TreeView1.Nodes.Add(, , "rootnode", "Sistem Kawalan Makmal")
  25.      
  26.         For intIDX = 1 To UBound(ServerList.List)
  27.             strServer = ServerList.List(intIDX).ServerName
  28.             t = strServer & intIDX
  29.             Set ch = TreeView1.Nodes.Add(rt, tvwChild, t, strServer)
  30.             rt.Expanded = True
  31.          
  32.         Next
  33.            
  34.     End If
  35.  
  36.  TreeView1.Nodes(1).Selected = True
  37.    strKEy = TreeView1.SelectedItem.Key
  38. End Sub
  39.  
  40. Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  41. Dim str
  42.  
  43. If strKEy <> "" Then
  44.     If TreeView1.Nodes(strKEy).Parent Is Nothing Then
  45.  
  46.         If Button = 2 Then ' if the mousebutton 2 is pressed (right)
  47.             PopupMenu Rclick ' then it calls the menu which is hidden to be shown at the cordinates of the mousepointer (x,y)
  48.  
  49.         Else
  50.  
  51.             Button = 1
  52.             RemoteHost = TreeView1.Nodes(strKEy).Text
  53.             sckControlPanel.RemoteHost = RemoteHost
  54.             sckControlPanel.RemotePort = 8005
  55.             sckControlPanel.Connect
  56.             MsgBox (" " & TreeView1.Nodes(strKEy).Text)
  57.         End If
  58.     End If
  59. Else
  60.  
  61. sckControlPanel.Close
  62. Call sckControlPanel_Close
  63.  
  64. End If
  65.  
  66. Data1.Refresh
  67. End Sub

Hai you guys, the above are the code to generate connected computer on the same network and displaying it in treeview. The problem here is the left click can't seem to function. I have tried putting a MsgBox at the button 1 to see what is it displaying when i click on the node and no matter what i click it will only display the root node name. This mean that i can't select the other computer name so it can't connect to the other computer.

RemoteHost = TreeView1.Nodes(strKEy).Text

Is there something wrong with this line. Can someone tell me what is wrong? Thanks in advanced