MikeInAustralia
asked on
How do I use mscomctl treeview in C#?
The attached code fails with "Element not Found" message when I try to create the root node. What arguments do I need with the Nodes.Add function to create a root node?
mscomctl.TreeViewClass treeview = (mscomctl.TreeViewClass)ctrlView.CreateControl("MSComctlLib.TreeCtrl.2");
object o = null;
object root = "root";
object rootTitle = "Root";
treeview.Nodes.Add(ref o, ref o, ref root, ref rootTitle, ref o, ref o);
It is restrictive to use the COM TreeView control in .NET, and C# has a native TreeView control, so I am curious why you need to use the COM version?
ASKER
Thanks for the reply - I agree that the native treeview is much easier to use but I don't think it is an option in my situation.
I am using a product called Processbook from OSIsoft. It is a graphical tool for viewing process data and it goes back to the early 90's. They provide a VS2005/2008 C# project template for creating an Addin for the application. Most of what want to achieve is available via the Processbook API but I also need a treeview and the COM version seems like my only option. They provide a Dockable Windows collection that can host Activex controls. I have attached another code snippet from the Processbook API doc showing the addition of a treeview to their PBControlView object.
If I could get the COM treeview to work the tools for the rest of my task is available in the Application's API. I think my basic problem is that I can't find any docs on the COM treeview control.
Am I doing something obviously wrong in the original code snippett that tries to create the parent node?
I am using a product called Processbook from OSIsoft. It is a graphical tool for viewing process data and it goes back to the early 90's. They provide a VS2005/2008 C# project template for creating an Addin for the application. Most of what want to achieve is available via the Processbook API but I also need a treeview and the COM version seems like my only option. They provide a Dockable Windows collection that can host Activex controls. I have attached another code snippet from the Processbook API doc showing the addition of a treeview to their PBControlView object.
If I could get the COM treeview to work the tools for the rest of my task is available in the Application's API. I think my basic problem is that I can't find any docs on the COM treeview control.
Am I doing something obviously wrong in the original code snippett that tries to create the parent node?
Dim cView As PBControlView
Dim oControl As Object
Add the View. This also adds one tab to the window
Set cView = cDockWnd.Views.Add(pbControlView,"My View")
Set oControl = cView.CreateControl("MSComctlLib.TreeCtrl.2")
You should be able to add a COM ActiveX control to the tool box, and drop a control on to a form, and use early-binding, instead of the late-bound method that it appears you are using.
ASKER
Not sure if I understand - if I am going to create a .net form I can use the .net treeview and forget the COM treeview but my form will not be part of the ProcessBook user interface. My aim was to put a treeview in the window provided by the Processbook to keep the interface consistent and it seemed a COM component was the only option. Maybe a separate .net form will save the hassle of the COM component ...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This sounds like it worth a try - thanks