How to get Windows native look for the .NET TreeView? -


trees

when using treeview component in .net, of left tree. how can of right tree (windows native look) .net treeview?

what want "triangle" node handles , blue "bubble" selection square.

you need p/invoke call setwindowtheme passing window handle of tree , use "explorer" theme.

paste following code new class in project, compile, , use custom control instead of built-in treeview control.

c#:

public class nativetreeview : system.windows.forms.treeview {     [dllimport("uxtheme.dll", charset = charset.unicode)]     private extern static int setwindowtheme(intptr hwnd, string pszsubappname,                                             string pszsubidlist);      protected override void createhandle()     {         base.createhandle();         setwindowtheme(this.handle, "explorer", null);     } } 

vb.net:

public class nativetreeview : inherits treeview      private declare unicode function setwindowtheme lib "uxtheme.dll"         (hwnd intptr, pszsubappname string, pszsubidlist string) integer      protected overrides sub createhandle()         mybase.createhandle()         setwindowtheme(me.handle, "explorer", nothing)     end sub  end class 

note trick works same way listview control.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -