C
Co
You're right, if it's added to an invisible Form, refreshing doesn't help..
In this case I've run out of ideas. From here it's hard to say. If you don't
create another instance of Explorer1, it should work.
Another attempt: What does the code to add the node look like? Are you
performing any long running actions directly after adding the node?
Armin
Armin,
this is what happens:
from frmZoeken I call the save to Treeview option in the menu:
Case "Opslaan"
SaveQueryInTreeview()
Private Sub SaveQueryInTreeview()
Dim sNewFolder As String = "Nieuwe Map"
Dim node = Explorer1.TreeView.TopNode
Dim nodeID = node.row("ID")
node.Nodes.Add(sNewFolder)
Explorer1.AddFolder2Database(nodeID, sNewFolder)
'Explorer1.TreeView.Refresh()
End Sub
From the main form Explorer1 the node is added.
Then the folder number is added to the database:
Public Sub AddFolder2Database(ByVal iParent As Integer, ByVal
sFolderName As String)
'this code will add a new folder to the database
conn.Open()
Dim sql As String = "SELECT * FROM Kabinet"
Dim strTable As String = "Kabinet"
Dim da As New OleDb.OleDbDataAdapter(sql, conn)
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim ds As New DataSet
Dim newRow As DataRow
cb.QuotePrefix = "["
cb.QuoteSuffix = "]"
Try
da.FillSchema(ds, SchemaType.Source, strTable)
newRow = ds.Tables(strTable).NewRow()
newRow("foldername") = sFolderName
newRow("parent-id") = iParent
'add the new row to the dataSet
ds.Tables(strTable).Rows.Add(newRow)
'sent the updated dataSet to the database
da.Update(ds, strTable)
Catch oException As OleDbException
MessageBox.Show(oException.Message)
Catch oException As Exception
MessageBox.Show(oException.Message)
End Try
conn.Close()
'now let's update the treeview with the new node.
TreeView.Nodes.Clear()
Call LoadTree()
End Sub
So everything here is done except that the newly added node isn't
shown.
Marco