如果树视图可滚动为false,则如何滚动树视图项 [英] How to scroll treeview items when treeview scrollable is false
本文介绍了如果树视图可滚动为false,则如何滚动树视图项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想重绘TreeView控件的滚动条,使用自绘控件覆盖原始,但我不知道如何操作,设置滚动条隐形,我不知道如何让节点滚动
我尝试过:
使用自绘控件覆盖原始,或尝试获取滚动条句柄
I would like to redraw the scroll bar of the TreeView control, using a self painted control to overwrite the original, but I don't know how to operate, set the scroll bar invisible, and I don't know how to make the nodes scroll
What I have tried:
using a self painted control to overwrite the original,or try to get scrollbar handle
推荐答案
如果是Winform,则将节点滚动到视图中:
If Winform, then to scroll a Node into view:
if(treeView.SelectedNode != null) treeView.SelectedNode.EnsureVisible();
更多信息: TreeNode.EnsureVisible方法(System.Windows.Forms) [ ^ ]
自定义绘制滚动条,这是一个简单的方法:如何在C#中为面板设置外观滚动条 [ ^ ]
使用API
[DllImport(user32.dll)]
[返回:MarshalAs(UnmanagedType.Bool)]
public static extern bool ShowScrollBar(IntPtr hWnd,int wBar,[MarshalAs] (UnmanagedType.Bool)] bool bShow);
Use API
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ShowScrollBar(IntPtr hWnd, int wBar, [MarshalAs(UnmanagedType.Bool)] bool bShow);
这篇关于如果树视图可滚动为false,则如何滚动树视图项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文