且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用自定义滚动条滚动TreeView

更新时间:2022-12-11 18:13:15

尝试这:

Try This:
vScrollBar1.Minimum = 0;
vScrollBar1.Maximum = treeView1.Nodes.Count;
vScrollBar1.Scroll += vScrollBar1_Scroll;

void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
    treeView1.Nodes[e.NewValue].EnsureVisible();
}



注意:滚动条的最大值必须是树视图节点数,因为它使用的是确保指定节点上的可见方法...


Note: that the Maximum value of the Scrollbar must be treeview node count, as it uses the EnsureVisible method on the specified node...