// Supports two blog entries by Daniel Moth: // http://www.danielmoth.com/Blog/2007/01/treeviewvista.html // AND // http://www.danielmoth.com/Blog/2006/12/tvsexautohscroll.html public class TreeViewVista : System.Windows.Forms.TreeView { protected override System.Windows.Forms.CreateParams CreateParams { get { System.Windows.Forms.CreateParams cp = base.CreateParams; cp.Style |= NativeMethods.TVS_NOHSCROLL; // lose the horizotnal scrollbar return cp; } } protected override void OnHandleCreated(System.EventArgs e) { base.OnHandleCreated(e); // get style int dw = NativeMethods.SendMessage(this.Handle, NativeMethods.TVM_GETEXTENDEDSTYLE, 0, 0); // Update style dw |= NativeMethods.TVS_EX_AUTOHSCROLL; // autoscroll horizontaly dw |= NativeMethods.TVS_EX_FADEINOUTEXPANDOS; // auto hide the +/- signs // set style NativeMethods.SendMessage(this.Handle, NativeMethods.TVM_SETEXTENDEDSTYLE, 0, dw); // little black/empty arrows and blue highlight on treenodes NativeMethods.SetWindowTheme(this.Handle, "explorer", null); } }