I have a wintree, outlook style, with a container containing a uttreeview with 2 levels Parent/Child.
I need to refresh the data in the tree without disturbing the current layout of the nodes (leave what is expanded expanded and what is collapsed collapsed) Like outlook does when you get mail. You don't notice anything in the navigation tree.
The data is updated by a system timer on a given interval.
Here is how I populate the data: public void LoadTreeView(){ dataSet.Tables.Add(dataHelper.GetDealer()); dataSet.Tables.Add(dataHelper.GetCars()); dataSet.Relations.Add (
Here is how I populate the data:
public void LoadTreeView(){ dataSet.Tables.Add(dataHelper.GetDealer()); dataSet.Tables.Add(dataHelper.GetCars()); dataSet.Relations.Add (
"fkDealerCars", dataSet.Tables["Dealers"].Columns["DealerID"], dataSet.Tables["Cars"].Columns["DeaterID"], false); utTree.SetDataBinding(dataSet, "Dealers"); ... ...}
public DataTable GetDealers(){ using (SqlConnection conn = new SqlConnection(ConnectionStr)) { conn.Open();
string sSQL = "proc_Dealers"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); using (SqlCommand cmd = new SqlCommand(sSQL, conn)) { sqlDataAdapter.SelectCommand = cmd; sqlDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure; sqlDataAdapter.SelectCommand.CommandTimeout = 300; DataTable dt = new DataTable("Dealers"); sqlDataAdapter.Fill(dt); return dt; } }}What is the best way to make this happen?
Gina_M
The control does not support this intrinsically. You would have to do something like store the nodes in a dictionary, perhaps with the underlying DataRow as the key, and then find the "old" node when the new one is created, then sync the expanded state. I'm not 100% certain this will work because I don't remember if the DataRow object will maintain its instance identity when you recreate the data source.
Is there a better way to interact with the treeview other than what I am doing?
-Gina_M
Can I populate the wintree as shown in the first post (via sql adapter...) then for a refresh "edit" the bound data behind the scenes to update the wintree with the new data?
If so (here is my lack of understanding "bound"). Would I modify the bound dataset:
dt = aDataset.Tables[
"Dealers"];dt.rows...Column["name"] = "ted"... (haven't figured this out yet)
or would I have to find the node in the wintree and edit the column value?
You might try this: dt.Rows["name"] = "ted" if you want to change the value of a cell in the row. The control should automatically hear that change and update itself accordingly, assuming the data source issues list changed notifications.