Allora, mi trovo sulla form DettagliDocumento (dove ho il treeview: TreeViewAllegati)
All'evento NuovoAllegato.Click
Adesso mi trovo sul form Allegato:codice:Private Sub NuovoAllegato_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NuovoAllegato.Click Dim FormAllegati As New Allegato FormAllegati.MdiParent = InformationArchive FormAllegati.WindowState = FormWindowState.Normal FormAllegati.StartPosition = FormStartPosition.CenterScreen FormAllegati.Action = 1 FormAllegati.ID_Informazione_Allegato = ID_Informazione FormAllegati.Show() End Sub
Inserisco il mio nuovo allegato e salvo il riferimento sul db. Adesso vorrei aggiornare il mio treeview richiamando una sub dichiarata public che si trova sempre nel form DettagliDocumento:
Ecco la Sub VisualizzaDettagli:codice:DettagliDocumento.VisualizzaDettagli()
Il problema è che non si aggiorna niente... ma l'interprete esegue correttamente tutte le righe!!codice:Dim NodeAllegati As TreeNode Me.TreeViewAllegati.AllowDrop = True TreeViewAllegati.BeginUpdate() TreeViewAllegati.SelectedNode = Nothing TreeViewAllegati.Nodes.Clear() TreeViewAllegati.Enabled = True OpenSqlConnection() Dim QueryAllegati As System.Data.SqlClient.SqlDataReader = CreateCommandReader("SELECT * FROM Allegati WHERE ID_Informazione=" & Me.ID_Informazione) While QueryAllegati.Read NodeAllegati = TreeViewAllegati.Nodes.Add(QueryAllegati("Titolo")) NodeAllegati.Name = QueryAllegati("ID_Allegato") End While QueryAllegati.Close() TreeViewAllegati.EndUpdate() CloseSqlConnection()

Rispondi quotando