C#的WinForms TreeView控件删除水平滚动条 [英] C# WinForms TreeView remove Horizontal Scrollbar
问题描述
我需要只垂直滚动条一个TreeView。
I need to have a TreeView with only vertical scrollbar.
我试过的这个,但它不工作,所产生的滚动条没有做任何事情。
I tried this but it doesnt work, the resulting scrollbar doesnt do anything at all.
我试过相反(与user32.dll中的功能滚动为true,禁用水平滚动条) - 它不工作,当我足够长的东西添加到TreeView滚动条再次表明...
I tried the opposite (scrollable to true and disable horizontal scrollbar with that user32.dll function) - it doesnt work, when i add long enough stuff to the TreeView the scrollbar shows again...
推荐答案
您可以尝试在TreeView控件打开在 TVS_NOHSCROLL 窗口样式。要做到这一点,你必须像这样一个自定义的树视图扩展标准TreeView控件:
You can try turning on the TVS_NOHSCROLL window style on the treeview control. To do so you have to extend the standard TreeView control with a custom TreeView like this one :
public class NoHScrollTree : TreeView {
protected override CreateParams CreateParams {
get {
CreateParams cp = base.CreateParams;
cp.Style |= 0x8000; // TVS_NOHSCROLL
return cp;
}
} }
这篇关于C#的WinForms TreeView控件删除水平滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!