# Scrolling / wxPanel / wxFlexGridSizer

**URL:** <https://www.ruby-forum.com/t/scrolling-wxpanel-wxflexgridsizer/199050>\
**Category:** wxRuby\
**Created:** [November 13, 2010, 1:05am UTC](https://www.ruby-forum.com/t/scrolling-wxpanel-wxflexgridsizer/199050 "2010-11-13T01:05:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 13, 2010, 1:05am UTC](https://www.ruby-forum.com/t/scrolling-wxpanel-wxflexgridsizer/199050/1 "2010-11-13T01:05:45Z")

</div>

I have a problem getting scroll bars to become active. Scrollbars  
appear but do not actually scroll. The problem I am trying to  
solve is to list a large number of key/value pairs. I looked  
to use PropertyGrid but did not find it in wxruby 2.0.1. I’m  
really stuck and would appreciate any help.

Thanks,  
Dave

Details:

I am starting with an .xrc file containing:  
…  
wxStaticBoxSizer (horizontal, stretch factor 1, expanded vertically)  
wxPanel (stretch factor 1, expanded vertically)  
…

In the ruby file invoking the interface I have:

require ‘wx’  
require ‘loadgui.rb’ # from xrcise

class MyApp \< MyGUI  
def on\_init  
# Sizer holding key value pairs  
@settings\_sizer = Wx::FlexGridSizer.new(2)  
@settings\_sizer.add\_growable\_col(1, 1)

```
# wxPanel holding the sizer above
@panel = @finder.call( 'ID_SETTINGS' )
@panel.sizer = @settings_sizer

@labels = {}
@texts = {}
ENV.each { |k, v|
  @labels[k] = Wx::StaticText.new(@panel, :label => k)
  @texts[k] = Wx::TextCtrl.new(@panel, :value => v)
  @settings_sizer.add @labels[k], 0
  @settings_sizer.add @texts[k], 1, Wx::EXPAND
}

```

end  
end

# Run the Application

Wx::App.run do  
$app = MyApp.new  
$app.show  
end

---

<div class="post-metadata">

**Author:** ![pazuzu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@pazuzu](https://www.ruby-forum.com/u/pazuzu)\
**Post date:** [November 13, 2010, 7:51am UTC](https://www.ruby-forum.com/t/scrolling-wxpanel-wxflexgridsizer/199050/2 "2010-11-13T07:51:33Z")

</div>

Hello Dave,

On Fri, Nov 12, 2010 at 7:05 PM, David I. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I have a problem getting scroll bars to become active. Scrollbars  
> appear but do not actually scroll. The problem I am trying to  
> solve is to list a large number of key/value pairs. I looked  
> to use PropertyGrid but did not find it in wxruby 2.0.1. I’m  
> really stuck and would appreciate any help.
> 
> Thanks,  
> Dave

We don’t have PropertyGrid available in 2.0.1, but we do have Wx::Grid  
available, which should allow you to use a Key \> Val pairs setup in it,  
as  
well as Wx::ListCtrl. Take a look at these two classes’ documentation,  
to  
see if it will help you.

[http://wxruby.rubyforge.org/doc/grid.html](http://wxruby.rubyforge.org/doc/grid.html)  
[http://wxruby.rubyforge.org/doc/listctrl.html](http://wxruby.rubyforge.org/doc/listctrl.html)

hth,

Mario

---

<div class="post-metadata">

**Author:** ![pazuzu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@pazuzu](https://www.ruby-forum.com/u/pazuzu)\
**Post date:** [November 16, 2010, 10:57pm UTC](https://www.ruby-forum.com/t/scrolling-wxpanel-wxflexgridsizer/199050/3 "2010-11-16T22:57:53Z")

</div>

Thanks for the help Mario.

I did look at grid and listctrl. I had hoped to use a FlexGridSizer  
instead, because I wanted columns of different sizes and to have  
one column grow. ListCtrl looks fairly complicated.

My problem seems to be getting the parenting or settings correct  
to have scrollbars work when I fill the FlexGridSizer beyond its  
window capacity. The scrollbars appear, using a settings of the  
wxPanel, but mouse clicks on them don’t cause scrolling.

My hierarchy looks like:  
…  
wxStaticBoxSizer (horizontal, stretch factor 1, expanded vertically)  
wxPanel (stretch factor 1, expanded vertically)  
wxFlexGridSizer (2 cols, col 1 growable, stretch factor 1)  
wxStaticText  
wxTextCtrl  
…  
wxStaticText  
wxTextCtrl  
…

Thanks,  
Dave
