how to eliminate a horizontal scroll bar in a treeview???

the horizontal scroll bar is getting displayed unneccessarily..

i need only the vertical scroll bar.




Answer this question

how to eliminate a horizontal scroll bar in a treeview???

  • Paul Stovell

    the contents are Loaded in form_load event only...

    is there any way to hide only the horizontal bar



  • Jeon

    I believe there is no direct way to do so in C#, as that property was not exposed. There're two way of investigation I can propose to you.

    1. Try to see if there is any Win32 API to do so. Usually, property that are not exposed can be set using Win32 API. However, that's all I can tell you because I didn't do that with TreeView before. (I did these dirty things with ListView thought)

    2. Try to see if you can disable all scrollbars in TreeView, and use a vertical scrollbar control, and blind them together by yourself.

    I believe it shouldn't be too difficult.



  • VladAll

    please explain more detail or show me your code,
    I try with your solution but it doesn't work.

    Many thanks,


  • ofsarac

    I don't have the tools to give you a full solution at this time. But here is a thread where I helped a other member by handling and sending messages, it should point you in the right direction:

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=330200&SiteID=1



  • Job Lot

    Very simple .

    put a panel in a form

    drop a tree view inside that panel

    set the tree view dock prop to fill

    treeView1.Dock = System.Windows.Forms.DockStyle.Fill;

    it will work


  • Radim Hampel

    a workaround would be to fill the contents of the treeview in the Form_Load event, as apperently this is a bug in .NET (unfortunately)

    it apperently happens in Windows XP or if you have enabled the visual styles.



  • velibicer

    I can't find a property to do this so it'll be hard to do. I'll see what I can dig up.

  • how to eliminate a horizontal scroll bar in a treeview???