Punim preko ridera i kako cita tako dodaje nod:
Code:
Private Sub Punitw1()'ovo je u loadu
com = New SqlCommand("select KLAS_ID,KLAS_NAZIV from ATC_OSNOVNA ", cnn)
cnn.Open()
RIDER = com.ExecuteReader()
Do While RIDER.Read
NAZIV = RIDER.Item("KLAS_NAZIV")
k = RIDER.Item("KLAS_ID")
NOD = New TreeNode()
tw1.Nodes.Add(NOD)
With NOD
.Tag = k
.Text = k & "--------" & NAZIV
End With
nod1 = New TreeNode()
NOD.Nodes.Add(nod1)
Loop
RIDER.Close()
com.Dispose()
cnn.Close()
End Sub
---------
Private Sub tw1_BeforeExpand(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles tw1.BeforeExpand
tw1.SelectedNode.Nodes.Clear() ' potrebno da se ne bi ponavljale stavke
Dim ass As String
ass = tw1.SelectedNode.Tag.ToString() 'uzimam vrednost iz tag propertija
com = New SqlCommand("select PODKLAS_ID1,PODKLAS_NAZIV1 from ATC_SEKUNDARNA1 where KLAS_ID = " & PrepareStr(ass) & " ")
cnn.Open()
com.Connection = cnn
RIDER = com.ExecuteReader()
Do While RIDER.Read
NAZIV = RIDER.Item("PODKLAS_NAZIV1")
k = RIDER.Item("PODKLAS_ID1")
nod1 = New TreeNode()
tw1.SelectedNode.Nodes.Add(nod1)
With nod1
.Tag = k
.Text = k & "--------" & NAZIV
End With
Loop
cnn.Close()
RIDER.Close()
RIDER = Nothing
com = Nothing
End Sub