Hi all.
I'm coding a project in visuel C#, and in VBA.
The connection between the two is made with a COM object.
I have created a TreeView in VBA with the librairie MSCOMCTL. And i want to send this TreeView Object to C#
The thing is that C# windows Forms TreeView seems to be not compatible with VBA MSCOMCTL treeView.
Is there any tips or idea to fix this ?
any help is welcome !
I'm coding a project in visuel C#, and in VBA.
The connection between the two is made with a COM object.
I have created a TreeView in VBA with the librairie MSCOMCTL. And i want to send this TreeView Object to C#
The thing is that C# windows Forms TreeView seems to be not compatible with VBA MSCOMCTL treeView.
Is there any tips or idea to fix this ?
any help is welcome !
VulpesPosted Aug 4, 2011, 9:39 AM
VulpesPosted Aug 8, 2011, 9:56 AM
If that works, you can then associate the ImageList object with the TreeView rather than trying to create your own programatically.
The only way to add images at runtime appears to be to use the LoadPicture() function which you mentioned earlier. However, I can't think of any way in which we can use that from C#.
plop plopPosted Aug 8, 2011, 9:45 AM
So i would rather add the images at "compile-time".
In fact, i'm not sure i can add images at run-time with a COM object ?
VulpesPosted Aug 8, 2011, 8:30 AM
Could you in fact do this or do you need to add the images to the control dynamically?
plop plopPosted Aug 8, 2011, 8:07 AM
VulpesPosted Aug 8, 2011, 6:40 AM
plop plopPosted Aug 8, 2011, 5:44 AM
But look at my code, it's what i did. I can't create an instance of listImages ... it has no contructor, plus it's a imageKistClass method.
In the link you found, they use a "loadPicture" method but it seems that there is no equivalent method to that ... or at least i can't find it ... that's why i use the "Bitmap.FromFile" method which i think is the cause of my issue.
VulpesPosted Aug 4, 2011, 11:51 AM
VulpesPosted Aug 4, 2011, 11:26 AM
Is there an Image class, or similar, included in MSCOMCTL.DLL that you could use instead?
plop plopPosted Aug 4, 2011, 10:50 AM
that's work perfectly ... but this solution leads to another question :
i'm trying to add an imageList to my treeview. Above the code :
object bt = Bitmap.FromFile("C:\\Documents and Settings\\...\\Incubation-16.ico");
object index = 0;
object name = "AM-Company";
mscomctl.ImageListClass status = new mscomctl.ImageListClass();
status.ListImages.Add(ref index,ref name,ref bt);
myTree.ImageList = status;
The error returned is : Invalid picture
I tried to load the picture with other methods ... the same error is displayed. If you have any solution to that i'm interested !
Thank you again ! thank you a lot !!!
plop plopPosted Aug 4, 2011, 8:22 AM
VulpesPosted Aug 4, 2011, 6:53 AM
If it is an index ID, I'd try using its key instead and see if the element can then be found.
plop plopPosted Aug 4, 2011, 2:13 AM
I changed the paramaters like you suggested :
myTree.Nodes.Add(ref id, ref RelationShip, ref CodePart, ref rootTitle, ref nullissimo1, ref nullissimo2);
Now the returned error is : Element not found.
VulpesPosted Aug 2, 2011, 5:03 PM
Are you able to determine which parameter is throwing the error?
I suspect it will be first one (Relative) and couldn't understand why it was the same as the third one (Key).
plop plopPosted Aug 2, 2011, 12:54 PM
foreach(PARTNERSHIP part in Partener)
{
object nullissimo = Type.Missing;
object CodePart = part.PARTNERSHIP_CODE.ToString();
object RelationShip = mscomctl.TreeRelationshipConstants.tvwFirst;
object rootTitle = part.PARTNERSHIP_NAME.ToString();
myTree.Nodes.Add(ref CodePart, ref RelationShip, ref CodePart, ref rootTitle, ref nullissimo, ref nullissimo);
}
myTree is a mscomctl.TreeViewClass
The error returned for the add method is : Element not found
I'm using Visual studio 2008, Microsoft Office 2003 on Windows XP.
Thank you again for your help.
VulpesPosted Aug 2, 2011, 12:11 PM
plop plopPosted Aug 2, 2011, 11:27 AM
Yes, i tried using the MSCOMCTL TreeView in my C# application. But i got issues with MSCOMCTL method.
i'm trying to resolve that since 2 days with any improvement.
I think that C# can't understand parameters of MSCOMCTL methods. For exemple, C# does not accept any argument for : myTreeView.Nodes.Add or at least has issues with it at compilation.
Is there any solution to build a MSCOMCTL treeview cleanly in C# ? i begin doubt about it !
VulpesPosted Aug 2, 2011, 10:46 AM
If you're using a 64-bit OS, then you may have problems using MSCOMCTL.OCX.
If relevant, check out this thread for a possible solution (http://www.c-sharpcorner.com/Forums/Thread/111898/mscomctl-ocx-raising-exception-in-64-bit-os-win-7.aspx).