ti posto il codice...
CODICE PRESENTE NEL FORM1 DOVE SI CARICA LA TREEVIEW :
Codice PHP:
'All' evento form1_load
'creo il nodo principale
'nodo principale UTENTI
Dim nodo2 As New TreeNode()
nodo2.Text = "Utenti"
TreeView.Nodes.Add(nodo2)
LoadTreeUser(nodo2)
TreeView.Nodes(1).ImageIndex = 2
TreeView.Nodes(1).SelectedImageIndex = 2
'procedura che carica e compila i nodi secondari
Public Sub LoadTreeUser(ByVal nodopadre As TreeNode)
'procedura in dataset su classe objuser
Dim ResultSet As DataSet = objuser.User()
If ResultSet.Tables.Count > 0 Then
Dim row As DataRow
For Each row In ResultSet.Tables(0).Rows
' Create the new node.
With nodopadre.Nodes.Add(row("Username").ToString)
.ImageIndex = 4
.SelectedImageIndex = 4
End With
Next
End If
End Sub
'sulla classe OBJUSER il dataset
Public Function User() As DataSet
Dim command As New SqlClient.SqlCommand
Dim Dataset As New DataSet
Datadapter = New SqlClient.SqlDataAdapter
command.Connection = cnn
command.CommandText = "select * from Utente order by User_id"
Datadapter.SelectCommand = command
Dataset.Clear()
Datadapter.Fill(Dataset, "Utente")
Return Dataset
End Function
'FORM2 CREA UN NUOVO USER
'SULL'EVENTO BTN_CREAUSER imposto le proprietà della classe in base alle txtbox di form2
'e lancio la procedura di insert presente anch'essa nella classe objuser
'sempre sull' evento di BTN dovrei aggiornare il FORM1