WF - TreeView
-
Hi, I have been trying to make a simple treeView list that should be poppulated by a SequentialWorkFlow.... However, I have not been successful. I Start the workflow instance, send it a TreeView in it's propperties and obtain this populated TreeView again in the Workflow_Completed event. But I can't simply assign this populated treeview to the existing TreeView component.... since this simply does not poppulated the TreeView list. I tired Update() ... but it did nothing. Sorry, I'm still relatively new to workflows. I've been looking around for a solution for some time now, and I have found none... I'm sure there is a simple solution, I just can't think of it. Any help would be much appreciated. Kind regards OnMouseClick.....
Dictionary<string,> properties = new Dictionary<string,>(); properties.Add("TreeNodes", \_theTreeView); properties.Add("BaseDN", m\_ConnectionSettings.BaseDN); properties.Add("LdapConn", m\_LDAPconnection); //PoppulateTree(m\_ConnectionSettings.BaseDN); // Poppulate the Tree consisting of units on server under Base DN. WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(Simulator.TreeViewStructure.ObtainTreeView), properties); instance.Start();
and then ...
void workflowRuntime_WorkflowCompleted(object sender, WorkflowCompletedEventArgs e)
{
TreeView val = (TreeView)e.OutputParameters["TreeNodes"];
treeView = val;
Update();
}I know the PoppulateTree function works, since it works fine if I don't do it in the workflow. Also, it's fine when I step through it.
-
Hi, I have been trying to make a simple treeView list that should be poppulated by a SequentialWorkFlow.... However, I have not been successful. I Start the workflow instance, send it a TreeView in it's propperties and obtain this populated TreeView again in the Workflow_Completed event. But I can't simply assign this populated treeview to the existing TreeView component.... since this simply does not poppulated the TreeView list. I tired Update() ... but it did nothing. Sorry, I'm still relatively new to workflows. I've been looking around for a solution for some time now, and I have found none... I'm sure there is a simple solution, I just can't think of it. Any help would be much appreciated. Kind regards OnMouseClick.....
Dictionary<string,> properties = new Dictionary<string,>(); properties.Add("TreeNodes", \_theTreeView); properties.Add("BaseDN", m\_ConnectionSettings.BaseDN); properties.Add("LdapConn", m\_LDAPconnection); //PoppulateTree(m\_ConnectionSettings.BaseDN); // Poppulate the Tree consisting of units on server under Base DN. WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(Simulator.TreeViewStructure.ObtainTreeView), properties); instance.Start();
and then ...
void workflowRuntime_WorkflowCompleted(object sender, WorkflowCompletedEventArgs e)
{
TreeView val = (TreeView)e.OutputParameters["TreeNodes"];
treeView = val;
Update();
}I know the PoppulateTree function works, since it works fine if I don't do it in the workflow. Also, it's fine when I step through it.
Any ideas .... PLZ ?
-
Hi, I have been trying to make a simple treeView list that should be poppulated by a SequentialWorkFlow.... However, I have not been successful. I Start the workflow instance, send it a TreeView in it's propperties and obtain this populated TreeView again in the Workflow_Completed event. But I can't simply assign this populated treeview to the existing TreeView component.... since this simply does not poppulated the TreeView list. I tired Update() ... but it did nothing. Sorry, I'm still relatively new to workflows. I've been looking around for a solution for some time now, and I have found none... I'm sure there is a simple solution, I just can't think of it. Any help would be much appreciated. Kind regards OnMouseClick.....
Dictionary<string,> properties = new Dictionary<string,>(); properties.Add("TreeNodes", \_theTreeView); properties.Add("BaseDN", m\_ConnectionSettings.BaseDN); properties.Add("LdapConn", m\_LDAPconnection); //PoppulateTree(m\_ConnectionSettings.BaseDN); // Poppulate the Tree consisting of units on server under Base DN. WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(Simulator.TreeViewStructure.ObtainTreeView), properties); instance.Start();
and then ...
void workflowRuntime_WorkflowCompleted(object sender, WorkflowCompletedEventArgs e)
{
TreeView val = (TreeView)e.OutputParameters["TreeNodes"];
treeView = val;
Update();
}I know the PoppulateTree function works, since it works fine if I don't do it in the workflow. Also, it's fine when I step through it.
You have to do your update work on the UI thread. The pattern is like this, adapted from one of the Microsoft samples (OrderingStateMachine).
private void Update()
{
if (this.InvokeRequired)
{
// This code is executing on a different thread than the one that
// ...created the TreeView, so we need to use the Invoke method.// Create an instance of the delegate for invoking this method UpdateDelegate update = new UpdateDelegate(this.Update); // Invoke this method on the UI thread this.Invoke(update); } else { // Insert your update code here; }
}
BTW, I highly recommend the book, Pro WF by Bruce Bukovics. This is in its VS 2008 edition now. I have the first edition.
Kevin
-
You have to do your update work on the UI thread. The pattern is like this, adapted from one of the Microsoft samples (OrderingStateMachine).
private void Update()
{
if (this.InvokeRequired)
{
// This code is executing on a different thread than the one that
// ...created the TreeView, so we need to use the Invoke method.// Create an instance of the delegate for invoking this method UpdateDelegate update = new UpdateDelegate(this.Update); // Invoke this method on the UI thread this.Invoke(update); } else { // Insert your update code here; }
}
BTW, I highly recommend the book, Pro WF by Bruce Bukovics. This is in its VS 2008 edition now. I have the first edition.
Kevin