# TreeCtrl Scrolling

**URL:** <https://www.ruby-forum.com/t/treectrl-scrolling/174525>\
**Category:** wxRuby\
**Created:** [August 28, 2009, 5:32am UTC](https://www.ruby-forum.com/t/treectrl-scrolling/174525 "2009-08-28T05:32:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lrosenman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b4bc9f/32.png) [@lrosenman](https://www.ruby-forum.com/u/lrosenman)\
**Post date:** [August 28, 2009, 5:32am UTC](https://www.ruby-forum.com/t/treectrl-scrolling/174525/1 "2009-08-28T05:32:34Z")

</div>

I have been playing around with the wxRuby TreeCtrl for a couple of  
weeks now and I can’t figure out how to get the scrolling to work. I  
believe it has scrolling built in but I can’t get the to show up. I can  
place the TreeCtrl in a ScrolledWindow and scroll around over the tree  
but that breaks TreeItem visibility checks because the TreeCtrl doesn’t  
know about it’s parent.  
When using the TreeCtrl in the Scrolled window the scroll bars work  
properly when I set the ScrolledWindow virtual size to the treectrl  
client size.  
But I don’t find any equivalent functionality in the treectrl itself.  
I’ve tried using it’s super (window) virtual size but that doesn’t seem  
to work either.  
The treectrl has some interesting methods like scrollto that make me  
believe it implements scrolling but I’m at a loss to make it work.  
Larry

---

<div class="post-metadata">

**Author:** ![lrosenman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b4bc9f/32.png) [@lrosenman](https://www.ruby-forum.com/u/lrosenman)\
**Post date:** [August 28, 2009, 6:13am UTC](https://www.ruby-forum.com/t/treectrl-scrolling/174525/2 "2009-08-28T06:13:59Z")

</div>

Larry Rogers wrote:

> I have been playing around with the wxRuby TreeCtrl for a couple of  
> weeks now and I can’t figure out how to get the scrolling to work. I  
> believe it has scrolling built in but I can’t get the to show up. I can  
> place the TreeCtrl in a ScrolledWindow and scroll around over the tree  
> but that breaks TreeItem visibility checks because the TreeCtrl doesn’t  
> know about it’s parent.

That sounds strange. With TreeCtrl the scroll bars should appear when  
they’re needed, and not when they’re not. It’s all handled by the widget  
itself - you definitely shouldn’t need to use another control like  
ScrolledWindow - just use Sizers (as in general) to manage the size of  
your widgets.

If this doesn’t help, could you post a minimal, runnable sample that  
reproduces the problem, and also a bit more info about your platform and  
version.

a

---

<div class="post-metadata">

**Author:** ![lrosenman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b4bc9f/32.png) [@lrosenman](https://www.ruby-forum.com/u/lrosenman)\
**Post date:** [August 29, 2009, 5:04am UTC](https://www.ruby-forum.com/t/treectrl-scrolling/174525/3 "2009-08-29T05:04:21Z")

</div>

Alex F. wrote:

> Larry Rogers wrote:

> That sounds strange. With TreeCtrl the scroll bars should appear when  
> they’re needed, and not when they’re not. It’s all handled by the widget  
> itself - you definitely shouldn’t need to use another control like  
> ScrolledWindow - just use Sizers (as in general) to manage the size of  
> your widgets.
> 
> If this doesn’t help, could you post a minimal, runnable sample that  
> reproduces the problem, and also a bit more info about your platform and  
> version.
> 
> a

Hi Alex,  
Thanks for your reply. I am encouraged that you say it should work the  
way my instincts said it should. I have tried many variations of  
Frame/Pane/TreeCtrl with and without sizers at each layer. What is  
different about my case is that I’m using wxSU on a Mac, which if you’re  
not familiar with it is an extension to Google Sketchup to use wxRuby to  
add 3rd party UI features. This is likely the source of my problem and  
it points me to another approach. I should get my UI running in wxRuby  
first and then adapt it to SketchUp. In doing so I will devise the  
example that you asked for and if it still doesn’t work I will post  
that.  
Thanks for the hints.  
Larry
