Author Topic: TreeView not working in AutoCAD 2015  (Read 2100 times)

0 Members and 1 Guest are viewing this topic.

mariana

  • Guest
TreeView not working in AutoCAD 2015
« on: July 08, 2014, 12:09:35 PM »
Hi all,

I've built a .net plugin that uses a System.Windows.Forms.Treeview inside a PaletteSet. It was working perfectly in Acad 2014 but now that I'm testing in 2015 I get this error when trying to add it to the PaletteSet:

System.ArgumentException: Control does not support transparent background colors.
   at System.Windows.Forms.Control.set_BackColor(Color value)
   at System.Windows.Forms.TreeView.set_BackColor(Color value)
   at Autodesk.AutoCAD.Windows.AcMgWinformPalette.ResyncToTheme(AcMgWinformPalette* )
   at Autodesk.AutoCAD.Windows.AcMgWinformPalette.Create(AcMgWinformPalette* , CAdUiPaletteSet* pParentWnd)
   at Autodesk.AutoCAD.Windows.PaletteSet.AddCore(String name, AcMgPalette* pPal)
   at ServiceManagementForm.InitializeComponent() in d:\Autodesk\Production\ServiceHierarchy\ServiceManagementForm.cs:line 166
   at ServiceManagementForm..ctor(ServiceManager _serviceManager) in d:\Autodesk\Production\ServiceHierarchy\ServiceManagementForm.cs:line 97


I've had a good google and it seems that my only options are to hack support for transparency into my System.Windows.Forms.Treeview or to port everything to WPF :(

Has anybody come across this issue with Acad 2015 and found a different solution?

Many thanks!

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: TreeView not working in AutoCAD 2015
« Reply #1 on: July 08, 2014, 02:18:49 PM »
Quote from: MSDN
The BackColor property does not support transparent colors unless the SupportsTransparentBackColor value of System.Windows.Forms.ControlStyles is set to true.
The BackColor property is an ambient property. An ambient property is a control property that, if not set, is retrieved from the parent control. For example, a Button will have the same BackColor as its parent Form by default. For more information about ambient properties, see the AmbientProperties class or the Control class overview.
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.backcolor(v=vs.110).aspx

Have you considered this?  From my ignorant chair it seems likely to cause your problem.

BTW I'm a supporter of WPF, I tried to set up interfaces through forms initially but found it very cumbersome for any customization.

nekitip

  • Guest
Re: TreeView not working in AutoCAD 2015
« Reply #2 on: July 08, 2014, 03:53:43 PM »
Not really of help to you, but I can confirm that treeview is working in 2015 but in WPF, have not tried winforms.
and some OT:
That being said, I'll use this opportunity to warn everyone who is planning to use large data in WPF treeview that there is still a strange microsoft bug in WPF virtualisation mode, manifesting itself, among other ways, in jerky scrolling and jumpy behaviour and you can google more about that. If using virutalisation recycling mode, artefacts are even stranger.
That bug is present from at least 2010, and it is still here, even though Microsoft states "closed" on that one.
Problem is solved only if you turn off virtualisation (you can do it if you have reasonably small amout of data so you don't care) or rethink your UI and to move to listbox and turn on virtualisation there.

mariana

  • Guest
Re: TreeView not working in AutoCAD 2015
« Reply #3 on: July 09, 2014, 05:49:04 AM »
I had looked at SupportsTransparentBackColor but hadn't really understood how to implement it correctly.

Thanks to Will's post I went back and looked further into it.

Turns out all I had to due is override the Treeview class like this:

namespace ServiceHierarchy {
   class MyTreeview : System.Windows.Forms.TreeView {

      public MyTreeview(): base() {
         this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
      }
   }
}


and now it's fixed!

Thanks very much for your input guys :)